Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Re-arrange a file!

Status
Not open for further replies.

abdu22

Programmer
Sep 13, 2005
14
FR
Hi,

I have an input file whose this format:

0.00000E+00 .0000 0.00000E+00 .0000 0.00000E+00 .0000 0.00000E+00 .0000
0.00000E+00 .0000 1.39259E-06 .0643 1.83690E-06 .0547 2.36873E-06 .0488
3.12521E-06 .0427 3.23615E-06 .0419 2.85301E-06 .0448 2.98344E-06 .0423
2.27548E-06 .0498 0.00000E+00 .0000 0.00000E+00 .0000 0.00000E+00 .0000
.
.
.

I want to print the $1" "$3" "$5" "$7" " of each line and print the results in output file with lines of 158 fields...
I used this commande line:

awk '{printf ($1"\n"$3"\n"$5"\n"$7"\n")}' input | awk 'BEGIN {j=0}{if (NF>0) printf ($1" "); j++;}{if (j>157) {printf ("\n"); j=0}}' > output

It works with this code but I'd like to know if there is another method more easy than this one..

Thanks
 
Thanks Annihilannic,, It's good idea.. :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top