Suchen heist nicht zwangsläufig auch finden


© Mai 2021, Letzte Änderung 06.06.26

--- still under construction ---

Übersicht

find

find Optionen Ordner/Datei [Parameter] kann verwenden um
Dateien oder Ordner zu finden.
Anbei ein paar gebräuchliche Parameter, welche üblicherweise Verunded werden.
Sollte das nicht gewünscht sein, kann -or oder -not verwendet werden.

Beispiel:

find . -maxdepth 1 -type f -name "*_case*"      suche im aktuellen Ordner 
./profile_case_d.pdf                            eine Datei welche "_case" enthält

find ~/sc/ -name '*.html'                       im Ordner ~/sc alle html-Dateien

find  ~/sc/ -newerct '48 hours ago' -name '*.jpg'
/home/m/sc/linux/shell/Thunar_x.jpg             -and ist default 
                                                -> kann weggelassen werden
find  ~/sc/ -name '*.jpg' -or -name '*.png'     keine Klammer gefunden 
                                                falls nötig a*(c+d) -> a*c + a*d
find  ~/sc/ -type f ! -name '*.html~'           alle Dateien außer .html~

 ionos.de   Linux find: Dateien suchen und finden
 ubuntuusers.de   find

Zum Anfang

file

file [Option] [Dateiname] um den Datei-Typ heraus zu bekommen.

Beispiele:

file profile_case_d.pdf 
profile_case_d.pdf: PDF document, version 1.7 (zip deflate encoded)

sudo file -sL /dev/sdb1
/dev/sdb1: DOS/MBR boot sector, code offset 0x58+2, OEM-ID "MSWIN4.1",
sectors/cluster 8, reserved sectors 2208, Media descriptor 0xf8, sectors/track 32,
heads 16, hidden sectors 8064, sectors 15671424 (volumes > 32 MB), FAT (32 bit),
sectors/FAT 15280, reserved 0x1, serial number 0xb2b53e74, label: "KINGSTON "

file ~/Down*/*
/home/m/Downloads/active_filter_2019-03-10(gerber_drill).zip: Zip archive data, at least v2.0 to extract, compression method=deflate
/home/m/Downloads/MiUnlock.png:       PNG image data, 1167 x 528, 8-bit/color RGB, non-interlaced
/home/m/Downloads/Popup.png:          PNG image data, 321 x 117, 8-bit/color RGB, non-interlaced

file -b Down*/[A-Z]*
PNG image data, 1167 x 528, 8-bit/color RGB, non-interlaced    (MiUnlock.png)
PNG image data, 321 x 117, 8-bit/color RGB, non-interlaced     (Popup.png)
 

 geeksforgeeks.org   file command in Linux with examples

Zum Anfang

uniq

uniq   um doppelte benachbarte Zeilen zu finden.
Falls die Zeilen nicht benachbart sind, hilft vorher sort .

Beispiel:

sort check.txt | uniq -w 64 -d
b5249000fb7ee9b2929c93dff8eae38d496e74d02f53b4d30a7e71f82360b3d9  3. Versuch

sort check.txt | uniq -w 64 -D
b5249000fb7ee9b2929c93dff8eae38d496e74d02f53b4d30a7e71f82360b3d9  3. Versuch
b5249000fb7ee9b2929c93dff8eae38d496e74d02f53b4d30a7e71f82360b3d9  MX-25_Xfce_x64.iso

cat check.txt 
b5249000fb7ee9b2929c93dff8eae38d496e74d02f53b4d30a7e71f82360b3d9  MX-25_Xfce_x64.iso
9eeb6848eee5995ce5a4e45b8c4a4701bf543a734b5c3c4b6e5161028498cbd9  02.12.25
f7534b109a3c4c6b62b067832d50a9f5d994ed457c57e7206c605176bdfe1a17  2. Versuch
b5249000fb7ee9b2929c93dff8eae38d496e74d02f53b4d30a7e71f82360b3d9  3. Versuch

 geeksforgeeks.org   file command in Linux with examples

Zum Anfang

word count

wc

Beispiel:

wc check.txt
  4  10 314 check.txt        4 Zeilen, 10 Wörter, 314 Bytes

 linuxize.com   file command in Linux with examples
 ubuntuusers.de   file command in Linux with examples
 tutonaut.de   file command in Linux with examples

Zum Anfang

cut

cut Spalten extrahieren

Mit dem Kommando cut werden hier die Benutzernamen (das 1. Feld) und die
Realnamen (das 5. Feld) aller in /etc/passwd eingeragenen Systembenutzer ausgegeben.

cut -d: -f1,5 /etc/passwd

 linuxize.com   file command in Linux with examples
 computerhope.com   file command in Linux with examples
 linoxide.com   file command in Linux with examples

Zum Anfang

sort

sort


 linuxhandbook.com   file command in Linux with examples
 ubuntuusers.de   file command in Linux with examples

Zum Anfang

Text replace

tr wortIn wortOut


 linuxhandbook.com   file command in Linux with examples
 linuxize.com   file command in Linux with examples
 linoxide.com   file command in Linux with examples

Zum Anfang

grep

grep


 kushellig.de   file command in Linux with examples
 linuxize.com   file command in Linux with examples
 howtoforge.de   file command in Linux with examples
 howtogeek.com   file command in Linux with examples
 prontosystems.org   file command in Linux with examples

Zum Anfang

tee

tee Umleitung


 howtoforge.de   file command in Linux with examples
 linuxize.com   file command in Linux with examples
 phoenixnap.com   file command in Linux with examples

Zum Anfang