Created
December 12, 2019 20:36
-
-
Save tofarley/5c582d56976bf1eb8322bb5613ce05bf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
given the file: | |
``` | |
this is a test | |
it is only a test | |
if this were an actual emergency | |
1 | |
2 | |
3 | |
4 | |
5 | |
``` | |
code: | |
``` | |
line=$(cat test.txt | grep -n 'this' | tail -1 | cut -d: -f 1) | |
cat test.txt | sed -n ${line},$(expr ${line} + 5)p | |
``` | |
output: | |
``` | |
if this were an actual emergency | |
1 | |
2 | |
3 | |
4 | |
5 | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment