Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Print lines in file from the match line until end of file

Tags:

sed

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?

like image 646
lidia Avatar asked Aug 08 '10 13:08

lidia


People also ask

How do you grep a line after a match?

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.

How do you grep 3 lines after a match?

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.

How do I get the lines of a file?

The wc -l command is the most used, and also the easiest way to find the line numbers of a given file.


1 Answers

sed -n '/matched/,$p' file awk '/matched/,0' file 
like image 142
ghostdog74 Avatar answered Sep 27 '22 17:09

ghostdog74