Stream Editor - Pattern Range


A pattern range can be a simple text or a complex regular expression.
NOTE:-We can use the character of dollar ($) to print all the lines after finding the first occurrence of the pattern.


\\The following example will help us to print the all the books of the author Paulo Coelho.

$ sed -n '/Paulo/ p' lfc.txt

4) The Alchemist, Paulo Coelho 

----------------------------------------------
----------------------------------------------

\\The following example prints lines starting with the first match of Alchemist until the fourth line.


$ sed -n '/Prince/, 4 p' books.txt

3) The Little Prince ,  Antoine de Saint
4) The Alchemist, Paulo Coelho 

---------------------------------------------
---------------------------------------------


\\The following example finds the first occurrence of the pattern The and immediately prints the remaining lines from the file

1) The Shadow of the Wind,  Carlos Ruiz Zafón
2) One Hundred Years of Solitude,  Gabriel García Márquez 
3) The Little Prince ,  Antoine de Saint
4) The Alchemist, Paulo Coelho 





Visit :


Discussion


* You must be logged in to add comment.