Per Stenebo
2011-11-04 20:50:50
2025-11-28 11:39:17
Sök
grep
| Ubuntu man page |
Sök efter text, visa filnamn:
grep -lir --include \*.py "some text" /path/*
The -l switch outputs only the names of files in which the text occurs (instead of each line containing the text), the -i switch ignores the case, and the -r descends into subdirectories. --include limit search to files with this extension.
Visa sista 10 rader som innehåller strängen error i filen /var/log/syslog, ignorera versalisering:
grep -i "error" /var/log/syslog | tail
find
| Ubuntu man page |
Sök alla filer med galaxy någonstans i filnamnet under mappen /opt, skiftlägesokänslig:
find /opt -iname '*galaxy*'
Sök filer som slutar med .txt (skiftlägesokänsligt) i /usr med undermappar:
find /usr -type f -iname '*.txt'
Find files modified last 60 days: find . -type f -mtime -60 | tutorial |
Bash command to find all .jpg files in subirs, sort them by file size, output the 10 largest files:
find . -type f -name "*.jpg" -printf '%s %p\n' | sort -nr | head -10