Sunday, March 14, 2010

awk example

http://www.linuxquestions.org/questions/programming-9/file-size-shell-script-377486/
http://www.ibm.com/developerworks/library/l-awk1.html
http://www.mindbend.org/scripts
http://www.thegeekstuff.com/2010/02/awk-conditional-statements/
ll | awk '/Pyrami/ {print $9}'

awk -F":" '{ print $1 }' /etc/passwd 
ll| awk '{if($9=="test"){ print $9} else print "6"}'


IFS=$'\012';
 for d in `find . -type d`;
 do s=$(ls -AlF $d | grep -v / | awk '{ $5 = $5/1024; sum += $5; } END \
 { print sum}') c=$(ls -AF $d|wc -l) ;
printf "%-20s" ${c} ${s}KB ${d} >>usage; printf "\n">>usage; done
ls -al | awk '{sum = sum + $5} END {print sum}'




find . \( -name "CORE_*" -o -name "c-*" \) -mtime -1 -exec ls -l {} \; |awk '/^-/ {total += $5} END {printf "%15.2f\n",total}'

find /path -mtime +1 -printf "%s\n"|awk '{sum+=$0}END{print sum}'

No comments:

Post a Comment

 Linux Interview  Linux booting process EXT4 XFS file system runlevel scan disk hba driver systool -c fc_host lspci -nn | grep -i hba single...