# Handy bash stuff # Converting tabs to spaces/spaces to tabs expand, unexpand # Changing case lc_table=`echo $table | tr '[A-Z]' '[a-z]'` # access to the first character in a string if [ "${line:0:1}" != "#" ] # Split a sentence into words var1="I have a question" set `echo var1` After that code executes, each word will be assigned to $1 $2 $3 $4. #To get: /tmp/my.dir (like dirname) path=${foo%/*} # Strip the path from the filename file=${foo##*/} unix command: basename #To get: filename base=${file%%.*} #To get the extension ext=${file#*.} # Remove leading spaces n=`expr $n` #Trim the shortest match from the end ${variable%pattern} #Trim the longest match from the beginning ${variable##pattern} #Trim the shortest match from the end ${variable%%pattern} #Trim the shortest match from the beginning ${variable#pattern} # access to everything after a delimiter extension=`echo $file | cut -d'.' -f2-` # array stuff # loading an array table_list[${#table_list[*]}]=$line # loading an array area2=( zero one two three four) # accessing array elements for i in "${table_list[@]}" for file in $( ls $ctlpath ) # or a more elegant method echo ${colors[@]} # number of elements in an array element_count=${#colors[@]} # Delete the contents of an entire array unset colors # Delete a certain element unset colors[1] # string concatenation str="${str}$var" # cut based on offset mod_line=`echo $line | cut -c8-100` # Fancy printing printf "%s%45s \n" NEW OLD >> $out