====== Shell scripting ====== === find === * Find the 25 biggest files into a filesystem: # find /var -xdev -type f -ls | sort +6nr | head -25 * Find the zero size files and modified in the 5 latest days: # find /var -mtime -5 -size 0c -ls === sed (AIX) === * Remove empty lines: # sed '/^$/d' * Add at the end of lines containing pattern a special character: # sed '/hdisk/ s/$/;/g' === tr (AIX) === * Remove / replace multiple characters, by one: # echo "abc;;;;123" | tr -s ';' abc;123 === bc (AIX) === * Use bc for decimal calcul # cap=$(echo 500G | sed 's/G/\*1024/' | sed 's/M//') # echo "scale=1;$cap" | bc 512000 http://www.shellunix.com/ksh.html