|
|
Zeile 1: |
Zeile 1: |
| __NOTOC__ | | __NOTOC__ |
| == Umgebung anpassen == | | === nützliche Shell-Befehle === |
| | |
| <pre><nowiki>
| |
| export EDITOR=vim
| |
| export VISUAL="$EDITOR"
| |
| export PAGER=less
| |
| export LESS='-i -M -e -Xi -R'
| |
| PS1="\[\033[1m\033[35m\]\! \u@\h:\w\n\[\033[1m\033[35m\]# \[\033[0m\]"
| |
| PS2="\[\033[1m\]>\[\033[0m\] "
| |
| PROMPT_COMMAND='RC=$?;
| |
| if [ $RC -ge 128 ]; then
| |
| SIG=$[RC-128];
| |
| echo -e "Signal $SIG = $(kill -l $SIG 2>/dev/null)";
| |
| fi;
| |
| if [ $RC -ne 0 ];
| |
| then echo -ne "\033[1m! (errno=$RC)\033[0m ";
| |
| fi
| |
| if [[ "$TERM" = xterm* ]]; then
| |
| echo -ne "\033]0;${USER}@${HOSTNAME}:${PWD}\007"
| |
| fi'
| |
| # Functions and Aliases
| |
| alias ..='cd ..'
| |
| alias mv='mv -i'
| |
| alias cp='cp -i'
| |
| unalias rm >&/dev/null
| |
| unalias ll >&/dev/null
| |
| function ll () { command ls -alF --color "$@" | less ;}
| |
| function psg () { ps auxw | fgrep "$@" | fgrep -v 'ps auxw' | fgrep -v fgrep ;}
| |
| </nowiki></pre>
| |
| | |
| | |
| == nützliche Shell-Befehle == | |
| | |
| [http://zoltanh721.linuxempire.hu/?p=454 Liste nützlicher Terminal-Programme]
| |
| [http://wiki.bash-hackers.org/scripting/terminalcodes Terminal codes]
| |
| | |
| Suchen und Ersetzen:
| |
| | |
| <pre><nowiki>
| |
| perl -i.backup -pe "s/PATTERN/SUBSTITUT/" DATEIEN
| |
| </nowiki></pre>
| |
| | |
| | |
| ACL-Rechte kopieren
| |
| | |
| <pre><nowiki>
| |
| getfacl Alte-Datei | setfacl --set-file=- Neue-Datei ...
| |
| </nowiki></pre>
| |
| | |
|
| |
|
| Sortieren von /etc/passwd nach UID: | | Sortieren von /etc/passwd nach UID: |
Zeile 90: |
Zeile 42: |
|
| |
|
| <pre><nowiki> | | <pre><nowiki> |
| ffmpeg2theora --two-pass --soft-target -V 600 -x 640 -y 480 -A 128 IMG_1296.MOV
| |
| HandBrakeCLI --preset 640x480 -2 -O -T -b 600 -X 640 -Y 480 -i IMG_1296.MOV -o IMG_1296.mp4
| |
| # ffmpeg braucht die exakte Zielgröße, also hier 640x360
| |
| ffmpeg -i IMG_1296.MOV -quality good -cpu-used 0 -b:v 600k -s 640x360 -f webm IMG_1296.webm
| |
| </nowiki></pre>
| |
|
| |
|
| |
| Liste der Filme erstellen:
| |
|
| |
| <pre><nowiki>
| |
| cd /data/Videos
| |
| (find Aufnahmen\ -\ geordnet/ -type l|egrep -v "\.tbn$"|sort; find Filme -type f |egrep -i "\.(mpeg|mov|mkv|avi|mp4)$"|sort) >/home/httpd/html/Filme.txt
| |
| </nowiki></pre>
| |
|
| |
|
|
| |
| Basisverzeichnisse in / sichern:
| |
|
| |
| <pre><nowiki>
| |
| cd /; /bin/ls | cpio -o -v > data/backup2/rootbase.cpio
| |
| </nowiki></pre>
| |
|
| |
|
| |
| Wiederherstellen mit:
| |
|
| |
| <pre><nowiki>
| |
| cpio -id < data/backup2/rootbase.cpio
| |
| </nowiki></pre>
| |
|
| |
|
| |
| Einloggen in gesperrten Account:
| |
|
| |
| <pre><nowiki>
| |
| su -s /bin/bash - apache
| |
| su -s /bin/bash apache -c ls
| |
| </nowiki></pre>
| |
|
| |
|
| |
| Leere Verzeichnisse löschen
| |
|
| |
| <pre><nowiki>
| |
| find -type d -empty -print0 | xargs --null rmdir
| |
| </nowiki></pre>
| |
|
| |
|
| |
| == MP3s ==
| |
|
| |
| MP3-Tag aus Dateinamen (mit mid3v2 aus python-mutagen)
| |
|
| |
| <pre><nowiki>
| |
| for i in *.mp3; do a=${i% -*}; t=${i#*- }; t=${t%.mp3}; mid3v2 -a "$a" -t "$t" "$i"; done
| |
| </nowiki></pre>
| |
|
| |
|
| |
| FLAC in MP3 umwandeln
| |
|
| |
| <pre><nowiki>
| |
| for a in *.flac; do < /dev/null ffmpeg -i "$a" -qscale:a 0 "${a[@]/%flac/mp3}"; done
| |
| </nowiki></pre>
| |
|
| |
| == Sprache erkennen ==
| |
|
| |
| Perl - Text übergeben
| |
|
| |
| <pre><nowiki>
| |
| perl -e 'use Lingua::Identify qw/:all/;set_active_languages("en", "de");print scalar langof({method => qw/smallwords prefixes2 prefixes3 prefixes4 suffixes2 suffixes3 suffixes4 ngrams2 ngrams3 ngrams4/}, $ARGV[0]),"\n"' "Dies ist ein Test"
| |
| </nowiki></pre>
| |
|
| |
|
| |
| Perl - Dateinamen übergeben
| |
|
| |
| <pre><nowiki>
| |
| perl -e 'use Lingua::Identify qw/:all/;set_active_languages("en", "de");print scalar langof_file({ encoding => "ISO-8859-1" }, $ARGV[0]),"\n"' /usr/share/dict/words
| |
| </nowiki></pre>
| |
|
| |
|
| |
| Python (https://github.com/saffsd/langid.py)
| |
|
| |
| <pre><nowiki>
| |
| langid <<< "Dies ist ein Test"
| |
| </nowiki></pre>
| |
|
| |
| == Umbenennen von Dateien ==
| |
| Unterstrich durch Leerzeichen ersetzen, Anfangsbuchstaben groß:
| |
|
| |
| <pre><nowiki>
| |
| for i in *; do mv "$i" "`echo $i|sed -e 's/-/ - /' -e 's/_/ /g'`"; done
| |
|
| |
| for i in *; do mv "$i" "`perl -e '$_=$ARGV[0];s/ (.)/uc(" $1")/ge;print' "$i"`"; done
| |
| </nowiki></pre>
| |
|
| |
|
| |
| Im Autoren-Verzeichnis:
| |
|
| |
| <pre><nowiki>
| |
| find . -maxdepth 1 -type f| while read i;do i=${i#./}; echo $i; echo $i|perl -e '$_ = <>; chomp; /^([A-Za-z]+?)[\. ]+(([A-Za-z]+?)\.? )?([A-Za-z'\''-]+?) (\(.+\) )?-/; $last = $4; $first = $1; $middle = $3; $middle = " ".$middle if $middle; $first.="." if $first =~ /^.$/; if ($last) {print "../Autoren/$last, $first$middle\n"} else {print "x\n"}'|(read dir; mkdir -p "$dir"; echo mv+ "$i" "$dir"; mv+ "$i" "$dir"); done
| |
|
| |
| find . -maxdepth 1 -type f|egrep -e '^./[a-zA-Z-]+, [a-zA-Z-]+ - '| while read i;do i=${i#./}; dir="${i%% - *}"; mkdir -p "$dir"; mv -v "$i" "$dir/$i"; done
| |
|
| |
| find . -type d|egrep -e '^./[a-zA-Z]+ [a-zA-Z]+$'| while read i; do i=${i#./}; first=${i% *}; last=${i#* }; mv -v "$i" "$last, $first"; done
| |
| </nowiki></pre>
| |
|
| |
|
| |
| Bilder auf Änderungsdatum.jpg umbenenen:
| |
|
| |
| <pre><nowiki>
| |
| for i in *.jpg; do j=`stat -c '%y' $i|cut -d. -f1|sed -e s/' '/_/`; if [ -e $j.jpg ]; then let x++; j=${j}_$x; else let x=0; fi; mv $i $j.jpg; done
| |
| </nowiki></pre>
| |
|
| |
|
| |
| Bilder in Verzeichnis mit Erstellungsdatum verschieben:
| |
|
| |
| <pre><nowiki>
| |
| for i in P10*; do mv $i $(perl -MPOSIX -e 'print strftime("%d.%m.%Y",localtime((stat $ARGV[0])[9]-32400)),"\n"' $i)/$i; done
| |
| for i in DSC*; do mv $i $(perl -e '$ARGV[0] =~ /(\d*):(\d*):(\d*)/; print "$3.$2.$1"' $(exiftool -CreateDate $i | cut -d" " -f 24))/$i; done
| |
| </nowiki></pre>
| |
|
| |
|
| |
| == Samba ==
| |
| Debuglevel setzen:
| |
|
| |
| <pre><nowiki>
| |
| smbcontrol smbd debug 10
| |
| </nowiki></pre> | | </nowiki></pre> |
|
| |
|
| ----
| |
| [[KategorieWissen]]
| |
|
| |
|
nützliche Shell-Befehle
Sortieren von /etc/passwd nach UID:
vipw
:%!sort -n -t: -k3
Testdatei schreiben mit periodischer Geschdindigkeitsanzeige:
i=1;while [ $i -lt 100 ]; do dd if=/dev/zero of=/testfile bs=102400 count=1 seek=${i}00; i=`expr $i + 1`; done
Bilder entsprechend der Orientieungsangabe in EXIF drehen:
for i in *.JPG; do rot=$(exiftool -S -IFD0:Orientation $i|grep -v normal); if [ -n "$rot" ]; then deg=$(echo $rot|cut -d" " -f3); echo $i:$deg; mv $i $i.orig; convert -rotate $deg $i.orig $i; exiftool -overwrite_original -n -Orientation=1 $i >/dev/null; fi; done
Format von Video/Image-Dateien ausgeben:
for i in *; do echo -n "$i: "; mediainfo --Inform="Video;%Width%x%Height%" $i; done
for i in *; do echo -n "$i: "; mediainfo --Inform="Image;%Width%x%Height%" $i; done
Thumbnail-Image aus Video generieren:
ffmpeg -itsoffset -4 -i IMG_1296.webm -vcodec mjpeg -vframes 1 -an -f rawvideo -s 320x240 IMG_1296.jpg
Videos auf Größe 640x480 skalieren: