The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 04-21-2009
fwellers fwellers is offline
Registered User
  
 

Join Date: Mar 2008
Location: Northern, VA
Posts: 23
awk routine help

Hi,
I use awk but not as a programming language. Just generally in piplelines to split things out by fields.
I am trying to accomplish this one thing that I think a short awk routine would do great for, but can't figure it out.

Lets say I have a file that contains database columns. The file looks like this:
col1
col2
col3
..

I want awk to go through that file and turn each line into an array element so that I can do a printf statement that would contain all the lines in the file in one statement. The statement would look something like this:

printf("%s,%s,%s\n", array[0],array[1],array[2])

Actually, I guess the array elements would be variablized also.

Is this a simple thing i can get some help with ?

Thanks,
Floyd