Quantcast
Viewing latest article 7
Browse Latest Browse All 8

Answer by schrodingerscatcuriosity for Show all lines before a match

Here's a solution with sed, given the content of file.txt:

barbazmoofooloozoo

command including pattern

tac file.txt | sed -n '/foo/,$p' | tac

output

barbazmoofoo

excluding pattern

tac file.txt | sed -n -e '/foo/,$p' | tac | sed -n '/foo/!p'barbazmoo

Viewing latest article 7
Browse Latest Browse All 8

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>