Linuxhotel Wiki

Wie ging das nochmal?

Benutzer-Werkzeuge

Webseiten-Werkzeuge


No renderer 'pdf' found for mode 'pdf'
lpi1:find

find

Aufgaben:

  • suche alle Dateien im System, deren Name ein Leerzeichen enthält.
  • suche alle leeren Dateien auf der Festplatte und gebe die Datei-Metadaten aus (Pseudo-Dateisysteme ausschließen)
  • Wie viele README-Dateien gibt es im System?
  • In welchen Verzeichnissen sind die meisten jpg-Bilder? 1)
  • Welches sind die am häufigsten vergebenen Berechtigungen im System? 2)
  • Alle Dateien mit hardlinks? 3)

exec & friends

cd
cp -a /usr/share/doc/ .
time find doc -type f -executable -exec chmod -x {} \;
time find doc -type f -executable -exec chmod -x {} +
find doc -type f -executable -print0 | xargs -0 -r chmod -x
# mit Zeitmessung (als shell gruppe)
time { find doc -type f -executable -print0 | xargs -0 -r chmod -x; }

Alle Dateien in ein Ziel kopieren

find . -type f -name "*na*" | xargs cp -t /tmp/eimer/

Ausgabe steuern

find / -type f -printf "%s %p\n" | sort -n | tac | head -5

nach Änderungszeit suchen

touch -d '12 hours ago'           /tmp/12_hours_ago
touch -d '1 day ago'              /tmp/1_day_ago
touch -d '1 day ago 12 hours ago' /tmp/1_day_ago_12_hours_ago
touch -d '2 days ago'             /tmp/2_days_ago
date -r /tmp/1_day_ago_12_hours_ago
find /tmp -name '*ago' -mtime -1 2> /dev/null
find /tmp -name '*ago' -mtime  1 2> /dev/null
find /tmp -name '*ago' -mtime +1 2> /dev/null
find /tmp -name '*ago' -mtime +0 2> /dev/null

find / -newermt '2017-01-01 9:00'

touch -d '2017-01-01 9:00' /tmp/stamp
find / -xdev -newer /tmp/stamp

nach Rechten suchen

find / -perm /u=x

nach Usern/Gruppen suchen

find / -user gabi
find / -gid 1002
find / -nouser; find / -nogroup
find ./Spielplatz -type l
find -L / -xdev -type l -ls 2>/dev/null
1)
find /usr/ -iname '*.jpg' -printf '%h\n' | uniq -c | sort -n
oder
find /usr/ -iname '*.jpg' | xargs dirname | sort | uniq -c | sort -n
2)
find / -xdev -type f -printf '%M\n' 2>/dev/null | sort | uniq -c | sort -n
3)
find . -type f -links +1 -ls
lpi1/find.txt · Zuletzt geändert: 2023/06/27 15:17 von natureshadow2