User Tools

Site Tools


ubuntu:file:print_every_line_in_a_file_matching_the_regular_expression

This is an old revision of the document!


Ubuntu - File - Print every line in a file matching the regular expression

Print the lines matching the regular expression. (emulates grep).

awk '/regex_here/' filename

Print the lines that don't match the regular expression. (emulates grep -v).

awk '!/regex_here/' filename

Print the line before the regular expression match.

awk '/regex_here/{print x};{x=$0}' filename

Print the line after the regular expression match.

awk '/regex_here/{getline; print}' filename
ubuntu/file/print_every_line_in_a_file_matching_the_regular_expression.1574889694.txt.gz ยท Last modified: 2020/07/15 09:30 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki