Skip to content

Instantly share code, notes, and snippets.

@4ft35t

4ft35t/result.md

Last active Dec 30, 2019
Embed
What would you like to do?
cat test.txt | sed  -n '/^start/,/^end/{/^start/,/i hate you/{/i hate you/p;};}'
i hate you 2
i hate you 4
i hate you 6
cat test.txt| awk '/start /{in_block=1; next} in_block && /i hate you/{t=$0; in_block=0; next} t && /end/{print t; t=""}'
i hate you 2
i hate you 4
i love you
i hate you 0
i hate you 0.1
end 0
movie starts
i hate you 1
start 1
i love you
i hate you 2
i hate you 3
end 1
end x
start 2
i love you
i hate you 4
i hate you 5
end 2
start 3
i love you
i hate you 6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment