Shell Scripting

Sequence

for i in {1..32}; do echo $i; done

Calculation

x=3
y=$(($x+4))

Quote Spaces in Filenames

echo $FILE | sed 's/ /\\ /g'

Remove lines beginning with XXX

sed -i -e '/^XXX_/d' /my/file"

Get yesterdays date

date +%Y:%m:%d -d "1 day ago"

Now in unix time

date +%s -d "now"

Find files modified after date

find . -type f -newermt 2012-12-24

Get lines where the nth element is bigger than x

perl -n -e '@a=split(/\s/,$_); print $_ if $a[3] > 2;'

Generate a random number

echo $RANDOM