Open Source Desktop Environment : BashShell

HomePage :: Categories :: PageIndex :: RecentChanges
Search this site:

bash

bash initialisation
When bash starts it first runs
BashRc
bash options
$ set -o
allexport       off
braceexpand     on
emacs           off
errexit         off
errtrace        off
functrace       off
hashall         on
histexpand      on
history         on
ignoreeof       off
...

bash for loop
$ for f in $(ls); do echo $f ; done
$ for f in /etc/sysconfig/*; do echo $(dirname $f) ; done
$ for f in /etc/sysconfig/*; do echo $(basename $f) ; done

bash arithmetic
$ x=1 ; x=$(($x+1)); echo $x

bash quoting quotes & backslashing backslashs
$ ls |  sed "s/\\\\/\\\\\\\\/g"

bash while
Iterate through file names and paths with spaces and backslashes
$ ls | while read -r f ; do ls -ld "$f" ; done

bash strip comments
Remove comments and blank lines
$ cat smb.conf | grep -v '^#' | grep -v '^;' |grep -v '^$'
[global]
        workgroup = MYGROUP
        server string = Samba Server
        printcap name = /etc/printcap
        load printers = yes
        cups options = raw
        log file = /var/log/samba/%m.log
        max log size = 50
        dns proxy = no
[homes]
        comment = Home Directories
        browseable = no
        writeable = yes

bash piping
piping output from grep to cut to sed to awk
vmware-cmd -l | while read -r vm
do
 cat "$vm" | grep scsi | grep name | cut -d "=" -f 2 | sed 's/"//g' | awk -F":" ' { print $NF } '
done


logfile analysis
$ grep -v '^#' *.log | cut -d " " -f 5,15 | grep "osde.info"


See GnuAwk GnuDiff GnuSed

REFERRERS
SysAdmin

There are no comments on this page. [Add comment]

Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by WikkaWiki
Page was generated in 0.0618 seconds