Shell
Dos 2 Unix
dos2unix dateiname dos2unix *
Cygwin rsync script Start
./sync_heilsarmee.sh
find Datei oder Ornder
Ordner Suchen und Finden:
find /var/www/ -type d -name "download_file" -print
Datei in Ordner Suchen und Finden
find /var/www/ -path "*/sites/all/modules/webform/components/select.inc" -print
Recursively chmod only directories or files
http://rainsoftletters.wordpress.com/2008/07/22/recursively-chmodi-only-directories-or-files/
Recursively chmod directories only.
bash
find . -type d -exec chmod 755 {} \+ # This will “find” all directories, starting at “.“, and chmod them to 755.
find . -type d -exec chmod g+w {} \+
or
chmod g-x `find . -type d` chmod 644 `find . -type d`
fish
chmod g+x (find . -type d)
Recursively chmod files only
bash
find . -type f -exec chmod 644 {} \+
or
chmod 644 `find . -type f`
This snippet does the opposite and finds only files. The difference (beside the file permissions) is the “-type f“, “f” specifies files and “d” directories. If you check the comments, you’LL3D find a few additional snippets:
find . -type f -name '*.htm*' -exec chmod 644 {} \+
This lets you “find” files (“-type f“) with a specific extension (“-name '*.htm*'“) and chmod them with your desired permission (“-exec chmod 644 {}“).
chmod -R o+rX
This snippet will recursively chmod “other” (“o“) permissions with read/eXecutable (“+rX“), and the capital X ensures that directories and files set (user/group permissions) to executable will be properly modified, while ignoring regular (non-executable) files.
fish
chmod g+x (find . -type f)
chmod 644 (find . -type f)
Find und Sed Befehle
find dev9*/web/themes/custom* -type f -name '*.less' -exec echo {} \; | sed -i 's/SUCHEN/ERSETZEN/g' {} \;
- grep
-r bedeutet rekursiv. -n zeigt die Zeile der Datei an, wo der Textschnipsel gefunden wurde. -w bedeutet, dass der Textschnipsel als Ganzes übereinstimmen muss. Wer nach „Haus“ mit -w sucht, findet nicht „Haustür“. -i bedeutet, dass nicht zwischen Groß- und Kleinschreibung unterschieden wird. -l kann optional ergänzt werden, um nur den Dateipfad auzugeben, in welcher der Textschnipsel vorkommt. --include "*.less" alle *.cpp: C++-Dateien (mit \ entkommen, nur für den Fall, dass Sie ein Verzeichnis mit Sternchen in den Dateinamen haben)
grep -rnwil 'DATEIPFAD' --include "*.less" -e 'SUCHSTRING'
grep -rnwil 'dev9/web/themes/custom/' --include "*.less" -e 'HANS' | xargs sed -i 's/HANS/SEPP/g'