I am new to awk programming and little confused about the use of NR variable ..
My code is ...
awk 'BEGIN {k=NR;}{printf("%s %s %s %s\n",$k,$(k+1),$(k+2),$(k+3))}' auth_data
$ cat auth_data
6262 6530 6661 3162 6364 6264 6561 3430 3033 3332 6536 3139 6230 6261 61
30 3637 0A00 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000
Output :
6262 6530 6661 3162 6364 6264 6561 3430 3033 3332 6536 3139 6230 6261 6130
3637 0A00 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 6262 6530 6661
But what I want is that output should be in this format :
6262 6530 6661 3162 6364 6264 6561 3430
3033 3332 6536 3139 6230 6261 6130 3637
0A00 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
I guess what you are looking for is NF, not NR.
from Manpage:
NR is actual line number, but in this problem, you want to do some trick on field idx, not lines.
Also, I thought your input data should be in one line in file 'auth_data', right?
if it is so, you could try
check the test below:
And back to the problem, if you just want to do the formatting, xargs is enough. see below:
output:
you can
cat yourFile|xargs -n8
orxargs -n8 -a yourfile