####
yes | head -20 | awk '{printf("HI%02d", NR)}'
####
Delete array[expr] cases array[expr] not to exist.
####
echo abc | mawk { gsub(//, "X") ; print }
XaXbXcX
'Cos if FS="""" (Empty) the awk breaks the record into individual characters.mawk recognizes the empty regular expression, //, which matches the empty string and hence is matched by any string at the front, back and between every character.
####
ls JUNK* | awk '{ print "mv "$0 " ~/tmp/"$0".tmp" }' | bash
mv all files match "JUNK*" to ~/tmp and append '.tmp' to their names.
####
gawk 'BEGIN{RS = "]" ; FS = "["}//[/{print $NF}' testfile
get all section names between [ and ]