I have to extract a a few lines from a log file and I know the starting String and end string(WHich is same ). Is there any simplere way using sed - awk.
e.g. from the following file
--------------------------------------
Some text
Date: 21 Oct 2008
Text to be extracted
Somemore text to be extracted
Date: 21 Oct 2008
Some more text
so I would like to extract the following lines
-------------
Text to be extracted
Somemore text to be extracted
---------------
I know the string "Date: 21 Oct 2008"
One way I can think of is do a grep -n "Date: 21 Oct 2008" filename and then user head and tail.
sed -n '/^start/,/^end/{/^start\|^end/!{p}}' testfile
where testfile is your file to search and start and end are the strings delimiting your pattern. This command will search every piece of text between a line starting with start and a line starting with end, inside this pattern it will print every line which doesn't start with "start" or "end".