If your file is less than, say, 10000 lines, you can do this:
grep -A 10000 show text.txt
The -A
flag will show the line containing the search string (show
) and the next 10000 lines.
However, I played around with the -A
flag a bit, and I noticed grep
will intelligently combine the output, so you don't get 10001 lines for each time the string show
is found. So basically, it will show you the whole file once, starting from the line that contains show
. If your file contains more than 10000 lines, adjust the parameter appropriately.
You can use the alias
command to create your own custom command to achieve the same result.
EDIT: a slightly more elegant solution would be to use
grep show -A $(wc -l < text.txt) text.txt
which will use the actual length of the file as the -A
flag. This requires you to specify the file name twice. Unfortunately this will prevent the use of an alias, but you could write a shell function to do this.
Apparently, in this case you need to specify the search string first to avoid an error.
start
in Ubuntu. And what comes directly after the pipe sign must be a command.grep -A 10000 show text.txt
, showing the line containingshow
and 10000 lines after it, which would work if your file is less than 10000 lines.alias start="grep -A 10000"
to have your single command. No need to pipe.