Linuxhotel Wiki

Wie ging das nochmal?

Benutzer-Werkzeuge

Webseiten-Werkzeuge


lpi1:find

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen gezeigt.

Link zu der Vergleichsansicht

Beide Seiten, vorherige Überarbeitung Vorherige Überarbeitung
Nächste Überarbeitung
Vorherige Überarbeitung
Nächste Überarbeitung Beide Seiten, nächste Überarbeitung
lpi1:find [2014/11/25 10:15]
ingo_wichmann
lpi1:find [2019/01/10 16:21]
ingo_wichmann [nach Rechten suchen]
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 '​*.jpg'​ -printf '​%h\n'​ | uniq -c | sort -n
 +oder
 +  find /usr/ -iname '​*.jpg'​ | xargs dirname | sort | uniq -c | sort -n
 +))
 +  * Welches sind die am häufigsten vergebenen Berechtigungen im System? ((
 +  find / -xdev -type f -printf '​%M\n'​ 2>/​dev/​null | sort | uniq -c | sort -n
 +))
 +
 +
 +===== exec & friends =====
   cd   cd
   cp -a /​usr/​share/​doc/​ .   cp -a /​usr/​share/​doc/​ .
   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; } 
 + 
 +===== 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' ​          /​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
   ​   ​
-[root@localhost ~]# touch -d '12 hours ago' /​tmp/​12_hours_ago +  ​touch -d '2017-01-01 9:00' /tmp/stamp 
-[root@localhost ~]# touch -d '1 day 12 hours ago' /​tmp/​1_day_12_hours_ago +  find / -xdev -newer /tmp/stamp 
-[root@localhost ~]# touch -d '1 day ago' /tmp/1_day_ago + 
-[root@localhost ~]#  +===== nach Rechten suchen ===== 
-[root@localhost ~]#  +  ​find / -perm /u=x 
-[root@localhost ~]# find /tmp -name '​*ago' ​-mtime -1 + 
-/tmp/12_hours_ago +===== nach Usern/Gruppen suchen ===== 
-/​tmp/​1_day_12_hours_ago +  ​find ​-user gabi 
-[root@localhost ~]# find /tmp -name '​*ago'​ -mtime 1 +  find / -gid 1002 
-/tmp/​1_day_ago +  find / -nouser; find / -nogroup
-/​tmp/​1_day__ago +
-[root@localhost ~]# rm /tmp/​1_day__ago +
-rm: remove regular empty file `/tmp/​1_day__ago'?​ y +
-[root@localhost ~]# find /tmp -name '​*ago'​ -mtime +1 +
-[root@localhost ~]# touch -d '2 days ago' /​tmp/​2_days_ago +
-[root@localhost ~]# find /tmp -name '​*ago'​ -mtime +1 +
-/tmp/​2_days_ago +
-[root@localhost ~]# date -r /​tmp/​1_day_12_hours_ago +
-Tue Nov 25 23:11:17 CET 2014+
  
lpi1/find.txt · Zuletzt geändert: 2023/06/27 15:17 von natureshadow2