grep¶
search in files¶
grep error *.log #list files and lines with `error`
grep error ../tst/*.log */*.log #from multiple folders
grep -h error *.log #exclude filenames
grep -c error *.log #count matches in each file (include zero match)
grep -l error *.log #list files with matches
grep -i error *.log #case insensitive search
grep -v error *.log #exclude lines with `error`
grep '[0-9]\{4\}-\{0,1\}[0-9]\{2\}-\{0,1\}[0-9]\{2\}' file #find a date
delete files with matches (confirm before delete)¶
search all files in the current folder, not subfolders
switch based on match¶
if multiple files provided, stop search after found 1st
search all files