name • file extensions are not important • File and folder names are case sensitive • Names containing spaces are escaped by \ or "" • Hidden files start with . • Current directory alias . and parent directory alias .. • ls, ls -a, ls -l, cp, mv, rm, rm -rdf, ln, ln -sf
or just written with spaces escaped by \ VAR=”How are you” VAR='How are you' VAR=HOW\ are\ you • Variables $VAR ${VAR} # e.g. ${FILE}.txt echo “my name is $NAME” echo “my name is “$NAME read VAR read VAR1 VAR2
done • For each loop for VAR in {1..5}; do echo $VAR; done for VAR in 1 2 3 4 5; do echo $VAR; done for VAR in {0..10..2}; do echo $VAR; done for VAR in $(seq 0 2 10); do echo $VAR; done • For loop with counter for (( i=0; i<=10; i+=2 )); do echo $i; done
9<>/dev/tcp/google.com/80 echo -e "GET / HTTP/1.0\n\n" >&9 while read line <&9; do echo $line; done • Named Pipes mkfifo pipe while read l; do echo $l; done < pipe echo “hi” > pipe # on another terminal window • Signal Processing #!/bin/bash function handle_signal () { echo "Hi man I got the signal" } trap "handle_signal; exit" SIGINT sleep 100
'{print $NF;}'` ussp-push 00:22:65:89:22:E6@9 "$1" "$NEW_FILE_NAME" • Close the computer when your browser finishes downloading your_file while true; do sleep 5; if [ -z "`fuser ~/your_file`" ]; then break; fi; done; sudo init 0 • Tell me the time whenever I lock my screen or unlock it • Simple spider using curl and wget • Log your time easily and report to a Redmine service • Think of more ...