Bash cheatsheet: Difference between revisions
From Lolly's Wiki
Jump to navigationJump to search
No edit summary |
|||
Line 1: | Line 1: | ||
=bash prompt= | |||
Put this in your ~/.bash_profile | |||
<source lang=bash> | |||
typeset +x PS1="\[\e]0;\u@\h: \w\a\]\u@\h:\w# " | |||
</source> | |||
=Nützliche Variablenersetzungen= | =Nützliche Variablenersetzungen= | ||
==dirname== | ==dirname== |
Revision as of 09:42, 28 October 2015
bash prompt
Put this in your ~/.bash_profile
typeset +x PS1="\[\e]0;\u@\h: \w\a\]\u@\h:\w# "
Nützliche Variablenersetzungen
dirname
$ myself=/usr/bin/blafasel ; echo ${myself%/*} /usr/bin
basename
$ myself=/usr/bin/blafasel ; echo ${myself##*/} blafasel
Schleifen
Zahlenfolgen
$ for i in {0..9} ; do echo $i ; done
oder
$ for ((i=0;i<=9;i++)); do echo $i; done
so gehen natürlich auch andere Sprünge, z.B. immer 3 weiter:
$ for ((i=0;i<=9;i+=3)); do echo $i; done
oder oder oder
$ for ((i=0,j=1;i<=9;i+=3,j++)); do echo "$i $j"; done
Rechnen
$ echo $[ 3 + 4 ] $ echo $[ 2 ** 8 ] # 2^8