awk - delimited output

Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users awk - delimited output
# 1  
Old 12-04-2007
awk - delimited output


I am looking for syntax in awk, where I am printing comma separated coulmns read from delimited file.

Say for e.g. awk -F":" '{print $1","$2","9}' fname

Instead of using "," withing print syntax,is there any way by which fields being printed will automatically get delimited by comma?

NOTE : Example mentioned above is just marginal subset of columns to be displayed.

Thanks in advace.
# 2  
Old 12-04-2007
awk -F":" -v OFS=',' '{print $1, $2, 9}' fname

This User Gave Thanks to vgersh99 For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Get the output of w command in pipe delimited format

Since output of w command have variable number of columns I want to get the output in pipe delimited format. I tried export OFS="|"; w but that does not work. Any ideas? (4 Replies)
Discussion started by: Soham
4 Replies

2. Shell Programming and Scripting

Output file with <Tab> or <Space> Delimited

Input file: xyz,pqrs.lmno,NA,NA,NA,NA,NA,NA,NA abcd,,NA,NA,NA,NA,NA,NA,NA Expected Output: xyz pqrs.lmno NA NA NA NA NA NA NA abcd NA NA NA NA NA NA NA Command Tried so far: awk -F"," 'BEGIN{OFS=" ";} {print}' $File_Path/File_Name.csv Issue:... (5 Replies)
Discussion started by: TechGyaann
5 Replies

3. Shell Programming and Scripting

Grep:pipe delimited output

Hi, I am trying to search for a string in a file and print all the matched lines as pipe delimited format. My command is cat m_gid_trans.XML|grep -i '<TABLEATTRIBUTE NAME ="Lookup cache directory name"' The output I am getting is <TABLEATTRIBUTE NAME ="Lookup cache directory name"... (4 Replies)
Discussion started by: sampoorna
4 Replies

4. Shell Programming and Scripting

How to output selective delimited data to a new file?

I have the following file which at times can be quite large so can be difficult to read, I need a script that just extracts particular delimited data and outputs to alternate file $cat fix1.log FIX4.4|0=12|55=LIT.L|48=123456|32=5|52=20111107-10:52:22.128|38=100|10=200| ... (6 Replies)
Discussion started by: Buddyluv
6 Replies

5. Shell Programming and Scripting

Pipe delimited output

Hi All, i have the following command df|awk '{print $5}'|grep /| egrep -v '^/$|/usr|/opt|/var/log|/home|/tmp' output looks like: /filesystem/number1 /filesystem/number2 /filesystem3 /possiblymoreoutput i want the output to look like the below (either in a file or to output to... (3 Replies)
Discussion started by: Tommyk
3 Replies

6. Shell Programming and Scripting

awk read one delimited file, search another delimited file

Hello folks, I have another doozy. I have two files. The first file has four fields in it. These four fields map to different locations in my second file. What I want to do is read the master file (file 2 - 23 fields) and compare each line against each record in file 1. If I get a match in all four... (4 Replies)
Discussion started by: dagamier
4 Replies

7. Shell Programming and Scripting

Linux - Script to generate the output delimited by Comma/Pipe

Hi All, I have a requirement where I need to go to a directory, list all the files that start with person* (for eg) & read the most recent file from the list of files. While browsing through the forum, i found that the command ls -t will list the files. I am trying to generate the output... (1 Reply)
Discussion started by: dsfreddie
1 Replies

8. Shell Programming and Scripting

Append output in tab delimited format

hello.. i m scripting in Perl and having issue writing the output in specific format..i read two files and run some commands and write output to one file. i want this to be a 2d table, File one has 48 rows and file two has 48 rows, first i take one id from file one, and go to second file, loop... (2 Replies)
Discussion started by: empyrean
2 Replies

9. Shell Programming and Scripting

Remote command output to file comma delimited

All, I am trying to run a command that will get the serial number, model, and hostname of a server and then output the 3 fields comma delimited. Then a new line to separate the 3 fields for each host. So, I run a for loop that reads in the list of hosts in a file and then runs these sudo... (0 Replies)
Discussion started by: markdjones82
0 Replies

10. Shell Programming and Scripting

Comma Delimited Output w/ egrep

Hi all, I have an input file that I am pulling out certain phases using the following commands: cat /nodes.txt | egrep -e 'OSVersion|PrimaryNodeName' Currently the output looks like this: OSVersion - 5.0 PrimaryNodeName - serverA OSVersion - 5.0 PrimaryNodeName - serverB OSVersion... (2 Replies)
Discussion started by: indianadoug
2 Replies
Login or Register to Ask a Question