ubuntu:file:display_every_line_in_a_file_matching_the_regular_expression
This is an old revision of the document!
Ubuntu - File - Display every line in a file matching the regular expression
Display the lines matching the regular expression. (emulates grep).
awk '/regex_here/' filename
Display the lines that don't match the regular expression. (emulates grep -v).
awk '!/regex_here/' filename
Display the line before the regular expression match.
awk '/regex_here/{print x};{x=$0}' filename
Display the line after the regular expression match.
awk '/regex_here/{getline; print}' filename
ubuntu/file/display_every_line_in_a_file_matching_the_regular_expression.1576439646.txt.gz ยท Last modified: 2020/07/15 09:30 (external edit)