Reputation: 2363
From the whole output I want to redirect everything between 2 given patterns (or lines)
An example scenario will be, I have a log file and I just want to see the logs printed after a specific pattern until another specific pattern is matched.
Anyone know any way for this to achieve using terminal commands ?
Upvotes: 1
Views: 61
Reputation: 95998
You can use grep
, sed
(or any other command that can use a regex) and use >
to redirect:
grep ... > file
Upvotes: 0
Reputation: 20768
Does /the/command | sed -n '/pattern1/,/pattern2/p' > /some/file
work for you?
Upvotes: 5