Week 8 Shell Scripting Basics Command files shell scripts test command [ for bash, sh and ksh ] if statement Loops Grep/egrep review [] {} \(\) ^ $ Shell Scripting Topics Quotes ' " ` and \ test command string comparison integer comparison file attribute check exit status command line arguments $1 $2 .. $9 ${10} $# $* "$@" Passing arguments from command line Shell variables user defined, positional and keyword if statement case statement for statement while statement egrep/grep review egrep '.*_.*CPU.*_.*_' egrep '^$' egrep '.' egrep '.*' ifconfig -a |grep "^[a-z0-9]*:" /usr/bin/egrep -v '^[ ]*(#|$)' /etc/dfs/dfstab /usr/bin/grep '^[ ]*share' /etc/rmmount.conf /usr/bin/dirname $0 | grep "/etc/rc" /usr/bin/grep -v \^\# /etc/defaultrouter /sbin/mount | /usr/bin/egrep '^/tmp(/| )' Egrep metacharacters . -> any single character [] -> set of characters, range of characters [ABC] [0-9] [^1234567890] examples: [1-9] [^A-Z123] root|bin --> alternation A|B --> match A or B * --> 0 or more occurrences of the prev. RE .* --> 0 or more occ. of any character. AB* --> A [a-m]* --> 0 or more occ. of lowercase a thru m + --> 1 or more occ. of the prev. RE .+ --> 1 or more of any character AB+ --> AB \{n\} --> exactly n occ. of the prev. RE ABC\{3\} --> ABCCC (ABC)\{3\} --> ABCABCABC