Analyze Text Files With Linux
Aus Matts Wiki
This page holds a knowledge base on how to analyse text files with linux.
See also:
Suchen in Dateien
grep -rnw /path/to/somewhere/ -e "<pattern>" grep -rni "<pattern>" [directory]
Nach "Search-Text" in allen Dateien unterhalb von / suchen:
find / -type f -exec grep -H '<Search-Text>' {} \;
Return all lines which do not -v contain a pattern -E:
grep -v -E "47.79|114.119|34.174|162.120|43.1|meta-|80.85|195.2"
Analyze
As described in Block Crawlers and Bots#Introduction
{ cat other_vhosts_access.log ; cat other_vhosts_access.log.1 ; zcat other_vhosts_access.log.?.gz ; } | grep meta-externalagent | awk '{print $1}' | sort | uniq -c | sort -nr | head -50
in detail also:
sort uniq head tail
Replace in Files
sed -i 's/jessie/stretch/g' filename # In Filename "jessie" finden und durch "stretch" ersetzen
