AWK NR Sample Script
I wrote about AWK NR in this article, so today I translate this one liner awk command to script. It is below.
#!/usr/bin/awk -f { for(i=6;i<=NF;i++){ printf "%s ", $i; } printf "\n"; }
Here is a log that executed above script.
$ echo "aaa bbb ccc ddd eee fff ggg hhh iii jjj kkk" > test.txt $ echo "aaa bbb ccc ddd eee fff ggg hhh iii jjj kkk" >> test.txt $ echo "aaa bbb ccc ddd eee fff ggg hhh iii jjj kkk" >> test.txt $ echo "aaa bbb ccc ddd eee fff ggg hhh iii jjj kkk" >> test.txt $ sudo /home/shimpei/a.awk test.txt $ cat test.txt aaa bbb ccc ddd eee fff ggg hhh iii jjj kkk aaa bbb ccc ddd eee fff ggg hhh iii jjj kkk aaa bbb ccc ddd eee fff ggg hhh iii jjj kkk aaa bbb ccc ddd eee fff ggg hhh iii jjj kkk $ $ $ ./a.awk test.txt fff ggg hhh iii jjj kkk fff ggg hhh iii jjj kkk fff ggg hhh iii jjj kkk fff ggg hhh iii jjj kkk $
This script is not perfect for me because valuable "i" used as for counter is hard coded. It is better that script detects the time-stamp automatically and define it. This point is my homework.