P E N C I L
Login

Bash

  1. http://www.tldp.org/LDP/Bash-Beginners-Guide/html/Bash-Beginners-Guide.html
  2. If
  3. function
    1. function myfunc() { $1}
    2. myfunc "abc"
  4. Wait until
    until grep -m 1 "4" a.txt; do sleep 1 ; done

  5. Call another bash:
    The following works:
    >>a.sh
    V1='x'
    >>b.sh
    . a.sh
    echo $V1
  6. sshpass
    read -s -p "Enter unix password:" PASS
    sshpass -p $PASS scp ....
  7. If
    1. Basic:
      If, then, fi are 3 commands (so they needs to be in separate lines or we have to add semicolon:
      ex: if [ "a" == "b" ]; then do something; something else; fi
      or : if [ "a" == "b" ]
            then do something
            something else
            fi
    2. Expression:
      (See:  Expressions used with if in reference Bash Beginner guide)
      1. [ "a" == "$var "]
      2. if  [ exp1 -o exp2  ]
        if [ exp1 -o exp2 ]

  8. exit $?;
  9. Utils
    1. $(basename /a/b) > "b"