Reputation: 9107
I want to be able to extract text in a bash script using sed starting at a certain line number and ending at a given pattern. Right now I have sed "${LINE_NUM}p;d" $FROM_FILE
, but that only returns the text on line number $LINE_NUM
. What if I want to get text starting at $LINE_NUM
going all the way down to some pattern of text?
Upvotes: 1
Views: 150
Reputation: 77175
You can do:
sed -n "${LINE_NUM},/regex/p" "$FROM_FILE"
Be sure to use word boundary \b
for text to get a perfect match instead of fuzzy.
Upvotes: 1