Open main menu

Changes

811 bytes added ,  11:18, 23 May 2016
adds recipes for grepping the line AFTER a matching pattern
# containing the regex
awk '/regex/{getline;print}'
# someone said somewhere that getline can pose problems.... dunno exactly what/why but here's an alternate
# This prints the 5th field of the line following the regex
# Then pipes it to grep with perl-compatible regex to use look-behind and look-ahead assertions to print the contents inside parenthesis
# so given an error log that contains the following two lines (repeatedly), and you want to extract the names of the tables
# Operation failed with exitcode 3
# 12:09:54 AM Dumping wordpress (log_civicrm_extension)
awk 'f{print $5;f=0} /Operation failed with exitcode/{f=1}' /tmp/mysqldump.error.log | sort | grep -P -o '(?<=\().*(?=\))'
## Admittedly this is more complex than just a couple greps!!
# grep -A1 /Operation failed with exitcode/ /tmp/mysqldump.error.log | sort | grep -P -o '(?<=\().*(?=\))'
# grep for AAA and BBB and CCC (in any order)
4,558

edits