Bash array operations – short table.

arr=() Create an empty array arr=(1 2 3) Initialize array ${arr[2]} Retrieve third element ${arr[@]} Retrieve all elements ${!arr[@]} Retrieve array indices ${#arr[@]} Calculate array size arr[0]=3 Overwrite 1st element arr+=(4) Append value(s) str=$(ls) Save ls output as a string arr=( $(ls) ) Save ls output as an array of files ${arr[@]:s:n} Retrieve n elements starting at index s

Bash – using mailx command to parse subjects

Problem:  It appears that the default mail -H appears to truncate the subject.  Grep fails to find text pass the email address. Fix:  Use Headline to format   echo ‘f 1-$’ | mail -H -S headline=”%>%a%m %20f %16d %3l/%-5o %i%150S” | grep -i ANZ535 | wc -l Here is what the issue looks like [ec2-user@jibsheet data]$ echo ‘f 1-$’ | […]