I wrote the following awk to print lines from the match line until EOF
awk '/match_line/,/*/' file
How can I do the same in sed?
You can use grep with -A n option to print N lines after matching lines. Using -B n option you can print N lines before matching lines. Using -C n option you can print N lines before and after matching lines.
For BSD or GNU grep you can use -B num to set how many lines before the match and -A num for the number of lines after the match. If you want the same number of lines before and after you can use -C num . This will show 3 lines before and 3 lines after.
The wc -l command is the most used, and also the easiest way to find the line numbers of a given file.
sed -n '/matched/,$p' file awk '/matched/,0' file
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With