displaying a column in horizontal line separated by ', '


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting displaying a column in horizontal line separated by ', '
# 1  
Old 01-24-2012
displaying a column in horizontal line separated by ', '

Code:
cat my.log
blah blah blah
< 1  djfh jsdfhk jksdfh
< 2  dshkfl opeir pqowi
< 4 khasd wouipeui

say i am perfroming some action similar to below...

Code:
cat my.log | egrep "<" | awk -F' ' '{print $2}' | grep -v "[A-Za-z]"

it gives output as below
Code:
1
2
4

is there anyway to modify above same command so that output is displayed like below

[CODE]1, 2, 4/CODE]

Last edited by vivek d r; 01-24-2012 at 07:02 AM..
# 2  
Old 01-24-2012
Hi

Code:
$ awk '/</{print $2}' my.log | paste -s -d,
1,2,4

Guru.
This User Gave Thanks to guruprasadpr For This Post:
# 3  
Old 01-24-2012
thanks a lot.. the code is working good :-). by chance is there anyway to output with space.. say like 1, 2, 4.. otherwise above is fine :-)
# 4  
Old 01-24-2012
try this too
Code:
tr "\n" " ," < vivek.txt > vivek_chgnd.txt


Last edited by Franklin52; 01-24-2012 at 09:22 AM.. Reason: Please use code tags for code and data samples, thank you
# 5  
Old 01-24-2012
Code:
awk '/</{print OFS $2}' my.log | paste -s -d,

--ahamed
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk to change comma separated line to horizontal

I am trying to change a file that looks like this: file, announcement,date, server, server01, server02, server06, file04, rec01, rec04, rec03... etc into a vertical file like this: file announcement date server server01 server02 server06 The file does not have to be sorted... (5 Replies)
Discussion started by: newbie2010
5 Replies

2. Emergency UNIX and Linux Support

Help parsing log from vertical to horizontal line

Hi Expert, i have log in attached (log.txt) i want the log result become horizontal line : recordOpeningTime,servedMSISDN,ratingGroup,datavolumeFBCUplink,datavolumeFBCDownlink 1502260153422B0800,196738930571,3,7946,2219 1502260153422B0800,196738930571,3,233,174... (4 Replies)
Discussion started by: justbow
4 Replies

3. Shell Programming and Scripting

Python Output Displaying Horizontal

I feel bad for posting so much lately. I've just been working on a project for fun to force myself to learn Python better. Recently I decided to incorporate this ping.py script on github found here. I'm not going to bore you with all the changes I made, but the problem now lies in this function... (8 Replies)
Discussion started by: Azrael
8 Replies

4. Shell Programming and Scripting

Change the vertical logs to horizontal line

Hi, cat log EPC-SubsId: 3333 EPC-GrIds: RTGHUPA:1:15-11-2013T19:59,22-11-2013T19:59 EPC-GrIds: PrimaXGB_23:10 EPC-SubsId: 4444 EPC-GrIds: RTGHUPB:1:15-11-2013T19:59,22-11-2013T19:59 EPC-SubId: 5555 EPC-GrIds: RTGHUPC:1:15-11-2013T19:59,22-11-2013T19:59 EPC-SubsId: 6666... (1 Reply)
Discussion started by: justbow
1 Replies

5. UNIX for Dummies Questions & Answers

How to move vertical line to Horizontal...

How to move a vertical line to Horizontal line.....Can i use a tr command? code is: StudentID Java .Net C# I want to move this line like this: StudentID Java .Net C# Please use code tags! (3 Replies)
Discussion started by: Arsh10
3 Replies

6. Shell Programming and Scripting

Print pipe separated list as line by line in Korn Shell

Korn Shell in AIX 6.1 I want to print the below shown pipe (|) separated list line by line. line=es349889|nhb882309|ts00293|snh03524|bg578835|bg37900|rnh00297|py882201|sg175883 for i in line do echo "Hello $line " done I wanted to execute the above for loop. But i can't even set the... (3 Replies)
Discussion started by: polavan
3 Replies

7. Shell Programming and Scripting

Draw a Horizontal and Vertical line on UNIX

I want to draw a horizontal and vertical line on Unix. Please suggest some solution. (11 Replies)
Discussion started by: allways4u21
11 Replies

8. Shell Programming and Scripting

plotting a straight horizontal line

How can I plot a straight horizontal line using perl in unix solaris environment? Please suggest. Pooja (2 Replies)
Discussion started by: wadhwa.pooja
2 Replies

9. UNIX for Dummies Questions & Answers

converting horizontal line to vertical line

how to use "tr" command to display horizontal line to vertical line for vertical to horizontal, the command is tr '\n' '\t' <inputfile but what is the command for horizontal to vertical Thanks Vasikaran (3 Replies)
Discussion started by: vasikaran
3 Replies
Login or Register to Ask a Question