Skip to content

Latest commit

 

History

History
36 lines (31 loc) · 851 Bytes

README.md

File metadata and controls

36 lines (31 loc) · 851 Bytes

AWK OPERATORS

AND

# any order
awk '/pattern1/ && /pattern2/' PATH
# specific order
awk '/pattern1.*pattern2/' PATH			

OR

awk '/pattern1|pattern2/' PATH

NOT

awk '!/pattern/' PATH

##Examples

  • Find all php files whose CONTENTS have changed in the last seven days and look for any strings that don't contain "nextend"
find -type f -name "*.php" -ctime -7 | sed -n '/nextend/!p'
find -type f -name '*.php' -ctime -7 | awk '!/nextend/'
  • Find all php files whose contents have changed between FIRST DATE and SECOND DATE
find -type f -name "*.php" -newerct 2016-01-29 ! -newerct 2016-02-24
  • Actively watch the access log and show all lines containing "POST" but not "404"
tail -f access_log | sed -n '/POST/!d; /404/!p'
tail -f access_log | awk '/POST/ && !/404/'