Reputation: 171
I have a file (df.txt) with 2 fields, but the first field has different size:
HOL99001 121112120001121122020112122010202121010100022002021................
804B 121202011100121121200010200120202220111200011002010....................
WW9 212202021000022111111111201001110001111200020200211.....................
I use a program that requires that the second field must start at the same position in different lines, thus:
HOL99001 121112120001121122020112122010202121010100022002021
804B 121202011100121121200010200120202220111200011002010
WW9 212202021000022111111111201001110001111200020200211
I am using
awk '{print $1.8, $2}' df.txt > dfinal.txt
Upvotes: 1
Views: 87
Reputation: 96
You could use:
gawk '{printf("%8s %s\n", $1, $2)}' df.txt
HOL99001 121112120001121122020112122010202121010100022002021
804B 121202011100121121200010200120202220111200011002010
WW9 212202021000022111111111201001110001111200020200211
or:
gawk '{printf("%-8s %s\n", $1, $2)}' df.txt
HOL99001 121112120001121122020112122010202121010100022002021
804B 121202011100121121200010200120202220111200011002010
WW9 212202021000022111111111201001110001111200020200211
Upvotes: 1