Einzeiler

Aus VDR Wiki
(Unterschied zwischen Versionen)
Wechseln zu: Navigation, Suche
K (Kategorie)
Zeile 1: Zeile 1:
 
==Einzeiler / Schnippsel==
 
==Einzeiler / Schnippsel==
<pre>
+
 
[SPLIT]
+
===SPLIT===
  
 
         split -b 95b xxxxxxxxxxx.tar.gz xxxxxxxxxxx.tar.gz.split.
 
         split -b 95b xxxxxxxxxxx.tar.gz xxxxxxxxxxx.tar.gz.split.
Zeile 7: Zeile 7:
 
         tar xvzf xxxxxxxxxxx.tar.gz
 
         tar xvzf xxxxxxxxxxx.tar.gz
  
[FIND/LS]
+
===FIND/LS===
  
 
         ls -lahS $(find / -type f -size +10000k)
 
         ls -lahS $(find / -type f -size +10000k)
Zeile 14: Zeile 14:
 
         find / -type d -exec du -sh {}  \; > /tmp/dirsizes.lst
 
         find / -type d -exec du -sh {}  \; > /tmp/dirsizes.lst
  
[SED/EUMULATION]
+
===SED/EUMULATION===
  
 
         cat          |  sed ':'
 
         cat          |  sed ':'
Zeile 43: Zeile 43:
 
         cp orig new  |  sed 'w new' orig
 
         cp orig new  |  sed 'w new' orig
  
[SED]
+
===SED===
  
 
         Einzelne Zeilen einer Datei können mit dem Kommando sed gelöscht werden.
 
         Einzelne Zeilen einer Datei können mit dem Kommando sed gelöscht werden.
Zeile 57: Zeile 57:
 
         sed -i "1i ..........."
 
         sed -i "1i ..........."
  
[CUT/TR]
+
===CUT/TR===
  
 
         cut -c 12-18      # die Zeichen 12 bis 18 jeder Zeile
 
         cut -c 12-18      # die Zeichen 12 bis 18 jeder Zeile
Zeile 64: Zeile 64:
 
         tr -d ' '        # alle blanks löschen
 
         tr -d ' '        # alle blanks löschen
  
[ZIP]
+
===ZIP===
  
 
         gzip file.diff [*.diff]      | führt zu file.diff.gz
 
         gzip file.diff [*.diff]      | führt zu file.diff.gz
Zeile 70: Zeile 70:
 
         tar cvIf dir.bz2 dir/*      | alle files in dir
 
         tar cvIf dir.bz2 dir/*      | alle files in dir
  
[WC/Emulation]
+
===WC/Emulation===
  
 
         stringZ=abcABC123ABCabc
 
         stringZ=abcABC123ABCabc
 
         echo ${#stringZ}
 
         echo ${#stringZ}
  
[INFO]
+
===INFO===
  
 
         awk '{ print $3 }' /proc/version
 
         awk '{ print $3 }' /proc/version
Zeile 90: Zeile 90:
 
         dmesg
 
         dmesg
  
[SCREEN]
+
===SCREEN===
  
 
         import -window root screen-`date "+%Y-%m-%d_%H:%M:%S"`.png
 
         import -window root screen-`date "+%Y-%m-%d_%H:%M:%S"`.png
  
[DATE]
+
===DATE===
  
 
         sh  | date +%s
 
         sh  | date +%s
Zeile 100: Zeile 100:
 
         awk  | awk 'BEGIN {print systime()}'
 
         awk  | awk 'BEGIN {print systime()}'
  
[SUBSTITUTION]
+
===SUBSTITUTION===
  
 
         a=/a/b/c/d
 
         a=/a/b/c/d
Zeile 132: Zeile 132:
 
         ${VARIABLE:+${WERT}} Nutzt den Wert, falls die Variable gesetzt ist, andernfalls nichts.
 
         ${VARIABLE:+${WERT}} Nutzt den Wert, falls die Variable gesetzt ist, andernfalls nichts.
  
[EXPANSION]
+
===EXPANSION===
  
 
         juergen@anna:~> line="foo bar cutoff baz cutoff fuz"
 
         juergen@anna:~> line="foo bar cutoff baz cutoff fuz"
Zeile 141: Zeile 141:
 
         fuz
 
         fuz
  
[ssh]
+
===ssh===
  
 
         ssh-keygen -t rsa1 -f /etc/ssh/ssh_host_key -N ""
 
         ssh-keygen -t rsa1 -f /etc/ssh/ssh_host_key -N ""
 
         ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N ""
 
         ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N ""
 
         ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key -N ""
 
         ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key -N ""
</pre>
+
 
 +
 
 +
[[Kategorie:Software]][[Kategorie:Skripte]]

Version vom 12. Mai 2007, 20:59 Uhr

Inhaltsverzeichnis

Einzeiler / Schnippsel

SPLIT

       split -b 95b xxxxxxxxxxx.tar.gz xxxxxxxxxxx.tar.gz.split.
       cat xxxxxxxxxxx.tar.gz.split.* > xxxxxxxxxxx.tar.gz
       tar xvzf xxxxxxxxxxx.tar.gz

FIND/LS

       ls -lahS $(find / -type f -size +10000k)
       find /video -follow -type d | grep -vEe ".(rec|del)$"
       find /cdrom/ -name *.deb -exec cp -v '{}' /var/cache/apt/archives ';'
       find / -type d -exec du -sh {}  \; > /tmp/dirsizes.lst

SED/EUMULATION

       cat          |  sed ':'
       cat -s       |  sed '/./,/^$/!d'
       tac          |  sed '1!G;h;$!d'
       grep         |  sed '/patt/!d'
       grep -v      |  sed '/patt/d'
       head         |  sed '10q'
       head -1      |  sed 'q'
       tail         |  sed -e ':a' -e '$q;N;11,$D;ba'
       tail -1      |  sed '$!d'
       tail -f      |  sed -u '/./!d'
       cut -c 10    |  sed 's/\(.\)\{10\}.*/\1/'
       cut -d: -f4  |  sed 's/\(\([^:]*\):\)\{4\}.*/\2/'
       tr A-Z a-z   |  sed 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'
       tr a-z A-Z   |  sed 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'
       tr -s ' '    |  sed 's/ \+/ /g'
       tr -d '\012' |  sed 'H;$!d;g;s/\n//g'
       wc -l        |  sed -n '$='
       uniq         |  sed 'N;/^\(.*\)\n\1$/!P;D'
       rev          |  sed '/\n/!G;s/\(.\)\(.*\n\)/&\2\1/;//D;s/.//'
       basename     |  sed 's,.*/,,'
       dirname      |  sed 's,[^/]*$,,'
       xargs        |  sed -e ':a' -e '$!N;s/\n/ /;ta'
       paste -sd:   |  sed -e ':a' -e '$!N;s/\n/:/;ta'
       cat -n       |  sed '=' | sed '$!N;s/\n/ /'
       grep -n      |  sed -n '/patt/{=;p;}' | sed '$!N;s/\n/:/'
       cp orig new  |  sed 'w new' orig

SED

       Einzelne Zeilen einer Datei können mit dem Kommando sed gelöscht werden.
       Das folgende Beispiel demonstriert, wie die erste, die letzte bzw.
       die zweite bis vierte Zeile aus einer Datei gelöscht werden.
       sed -e '1d' file
       sed -e '$d' file
       sed -e '2,4d' file
       sed -n '4p' file
       sed -i "1a ..........."
       sed -i "1i ..........."

CUT/TR

       cut -c 12-18      # die Zeichen 12 bis 18 jeder Zeile
       cut -f 2 -d ' '   # das 2.Feld, Feldtrenner ist ' '(blank)
       tr -s '[:blank:]' # sqeeze meherere blanks-> ein blank
       tr -d ' '         # alle blanks löschen

ZIP

       gzip file.diff [*.diff]      | führt zu file.diff.gz
       bzip2 -kv file.diff [*.diff] | führt zu file.diff.bz2
       tar cvIf dir.bz2 dir/*       | alle files in dir

WC/Emulation

       stringZ=abcABC123ABCabc
       echo ${#stringZ}

INFO

       awk '{ print $3 }' /proc/version
       awk '/model name/ {print $4}' < /proc/cpuinfo
       awk '/model name/ { print"" $4" "$5" "$6 }' < /proc/cpuinfo
       awk '/cpu MHz/ { print "MHz    " $4 }' < /proc/cpuinfo
       awk '{ print "Kernel "$3 }' /proc/version
       cat /proc/interrupts
       cat /proc/net/dev
       cat /proc/pci
       lspci -v
       uname
       lsmod
       dmesg

SCREEN

       import -window root screen-`date "+%Y-%m-%d_%H:%M:%S"`.png

DATE

       sh   | date +%s
       perl | perl -le 'print time'
       awk  | awk 'BEGIN {print systime()}'

SUBSTITUTION

       a=/a/b/c/d
       b=b.xxx
       csh        bash                result
       ----        --------        ------
       $a:h        ${a%/*}                /a/b/c
       $a:t        ${a##*/}        d
       $b:r        ${b%.*}                b
       $b:e        ${b##*.}        xxx
       ${VAR#pattern} removes the shortest matching pattern, anchored at
       the beginning of the string.
       ${VAR##pattern} removes the longest matching pattern, anchored at
       the beginning of the string.
       ${VAR%pattern} removes the shortest matching pattern, anchored at
       the end of the string.

       ${VAR%%pattern} removes the longest matching pattern, anchored at
       the end of the string.
       ${VARIABLE:-${WERT}} Nutzt den Wert von Variable. Falls die Variable nicht gesetzt ist, wird der Wert benutzt.
       ${VARIABLE:=${WERT}} Nutzt den Wert von Variable. Falls die Variable nicht gesetzt ist, wird der Wert benutzt, und Variable erhält den Wert.
       ${VARIABLE:?${WERT}} Nutzt den Wert von Variable. Falls die Variable nicht gesetzt ist, wird der Wert ausgegeben und die Shell beendet.
                            Wenn kein Wert angegeben wurde, wird der Text parameter null or not set ausgegeben.
       ${VARIABLE:+${WERT}} Nutzt den Wert, falls die Variable gesetzt ist, andernfalls nichts.

EXPANSION

       juergen@anna:~> line="foo bar cutoff baz cutoff fuz"
       juergen@anna:~> text='cutoff'
       juergen@anna:~> echo "${line#*$text}"
       baz cutoff fuz
       juergen@anna:~> echo "${line##*$text}"
       fuz

ssh

       ssh-keygen -t rsa1 -f /etc/ssh/ssh_host_key -N ""
       ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N ""
       ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key -N ""