AWK tips

Published: Wednesday, Dec 26, 2007 Last modified: Thursday, Nov 14, 2024

Every now and then, some shows me something I should know :

(du -a | awk '{print }' | grep '\.JPG' | xargs jhead)
for i in `du -a | awk '{print $2}' | grep '\.JPG'`; do cp $i ~/kodak; done

First field:

apt-cache search mp3 | awk '{print $1}'

Last field:

apt-cache search mp3 | awk '{print $NF}'

Everything except first column:

awk '{ for (i=2; i<=NF; i++) printf "%s ", $i; printf "\n"; }'

I want to remove the first column. So everything BUT awk '{print $1}'

awk '{$1="";print $0}'