lpi1:find
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen der Seite angezeigt.
| Beide Seiten, vorherige ÜberarbeitungVorherige ÜberarbeitungNächste Überarbeitung | Vorherige Überarbeitung | ||
| lpi1:find [2014/11/25 10:15] – ingo_wichmann | lpi1:find [2023/06/27 15:17] (aktuell) – [nach Änderungszeit suchen] find -newermt natureshadow2 | ||
|---|---|---|---|
| Zeile 1: | Zeile 1: | ||
| ====== 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? (( | ||
| + | find /usr/ -iname ' | ||
| + | oder | ||
| + | find /usr/ -iname ' | ||
| + | )) | ||
| + | * Welches sind die am häufigsten vergebenen Berechtigungen im System? (( | ||
| + | find / -xdev -type f -printf ' | ||
| + | )) | ||
| + | * Alle Dateien mit hardlinks? ((find . -type f -links +1 -ls)) | ||
| + | |||
| + | |||
| + | ===== exec & friends ===== | ||
| cd | cd | ||
| cp -a / | cp -a / | ||
| time find doc -type f -executable -exec chmod -x {} \; | time find doc -type f -executable -exec chmod -x {} \; | ||
| - | 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 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 " | ||
| + | ===== Ausgabe steuern ===== | ||
| - | find / -xdev -uid 1002 -exec chown root {} \; | ||
| find / -type f -printf "%s %p\n" | sort -n | tac | head -5 | find / -type f -printf "%s %p\n" | sort -n | tac | head -5 | ||
| + | |||
| + | ===== nach Änderungszeit suchen ===== | ||
| + | touch -d '12 hours ago' | ||
| + | touch -d '1 day ago' | ||
| + | touch -d '1 day ago 12 hours ago' / | ||
| + | touch -d '2 days ago' | ||
| + | |||
| + | date -r / | ||
| + | |||
| + | find /tmp -name ' | ||
| + | find /tmp -name ' | ||
| + | find /tmp -name ' | ||
| + | find /tmp -name ' | ||
| | | ||
| - | [root@localhost ~]# touch -d '12 hours ago' | + | find / -newermt |
| - | [root@localhost ~]# touch -d '1 day 12 hours ago' / | + | |
| - | [root@localhost ~]# touch -d '1 day ago' /tmp/1_day_ago | + | |
| - | [root@localhost ~]# | + | find / -xdev -newer /tmp/stamp |
| - | [root@localhost ~]# | + | |
| - | [root@localhost ~]# find /tmp -name ' | + | ===== nach Rechten suchen ===== |
| - | /tmp/12_hours_ago | + | |
| - | / | + | |
| - | [root@localhost ~]# find /tmp -name ' | + | ===== nach Usern/Gruppen suchen ===== |
| - | /tmp/ | + | |
| - | / | + | find / -gid 1002 |
| - | [root@localhost ~]# rm /tmp/ | + | find / -nouser; find / -nogroup |
| - | rm: remove regular empty file `/tmp/ | + | |
| - | [root@localhost ~]# find /tmp -name ' | + | |
| - | [root@localhost ~]# touch -d '2 days ago' / | + | |
| - | [root@localhost ~]# find /tmp -name ' | + | |
| - | /tmp/ | + | |
| - | [root@localhost ~]# date -r / | + | |
| - | Tue Nov 25 23:11:17 CET 2014 | + | |
| + | ===== nach Symlinks suchen ===== | ||
| + | find ./ | ||
| + | ==== verwaiste Symlinks ==== | ||
| + | find -L / -xdev -type l -ls 2>/ | ||
lpi1/find.1416910517.txt.gz · Zuletzt geändert: 2014/11/25 10:15 (Externe Bearbeitung)
