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!

I am an AWK newbee and am trying to create an output of every 3 lines 1

Status
Not open for further replies.

123tips

Technical User
Nov 13, 2007
3
US
I have an input text file that looks like:

\\awpvcp01
Rev 1.7
Last modified:
\\awpvcp01
Rev 1.6
Last modified:

I am trying AWK to get this output:

\\awpvcp01 Rev 1.7 Last modified:
\\awpvcp01 Rev 1.6 Last modified:

Am I trying to make this harder than it should be? Here is my attempt:

awk 'BEGIN {
FS="\n"
RS=""
i=0
x=1
y=2
z=3
{do
{print "TEST",$(NF-(NF-x)),$(NF-(NF-y)),$(NF-(NF-z))
i++
x=x+3
y=y+3
z=z+3}
while (i<NF)}}'

Major problem is that I don't know how to get the input file to be read or the output file to be generated. Any help would be appreciated.

 
A starting point (in an unix shell):
Code:
awk '{printf "%s ",$0}!(NR%3){printf "\n"}' /path/to/input > output

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks PHV! That worked great! Is it possible to get the output into 3 columns?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top