Reputation: 79
I have a text file that reads like:
hello
We're so
excited to
be learning computer
science today
HOORAY
hooraaaay
I'm trying to extract:
We're so
excited to
be learning computer
science today
HOORAY
so everything between "We're" and "HOORAY" including the two words.
I'm using the command:
sed -n "/^We're so/,/^ HOORAY/p" file.txt
But it's not working (it doesn't stop after HOORAY). How would I fix this? Is there another way to approach the command?
Upvotes: 4
Views: 71
Reputation: 133528
This simple sed
may help you on same.
sed -n "/We're/,/HOORAY/p" Input_file
Solution 2nd: Using awk
too.
awk '/We\047re/,/HOORAY/' Input_file
Upvotes: 3