Change the vertical logs to horizontal line


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Change the vertical logs to horizontal line
# 1  
Old 12-12-2013
Change the vertical logs to horizontal line

Hi,

cat log
Code:
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
EPC-GrIds: RTGHUPD:1:15-11-2013T19:59,22-11-2013T19:59
EPC-GrIds: 4PrimaSGB_23:10


I want the results become :

Code:
3333 RTGHUPA:1:15-11-2013T19:59,22-11-2013T19:59 PrimaXGB_23:10
4444 RTGHUPB:1:15-11-2013T19:59,22-11-2013T19:59 
5555 RTGHUPC:1:15-11-2013T19:59,22-11-2013T19:59 
6666 RTGHUPD:1:15-11-2013T19:59,22-11-2013T19:59 4PrimaSGB_23:10

Anybody can help ?

Thanks.
# 2  
Old 12-12-2013
Code:
$ awk '{printf NF ? $2 OFS : RS}END{printf RS}' file

Code:
3333 RTGHUPA:1:15-11-2013T19:59,22-11-2013T19:59 PrimaXGB_23:10 
4444 RTGHUPB:1:15-11-2013T19:59,22-11-2013T19:59 
5555 RTGHUPC:1:15-11-2013T19:59,22-11-2013T19:59 
6666 RTGHUPD:1:15-11-2013T19:59,22-11-2013T19:59 4PrimaSGB_23:10

--edit---


if your log file contains multiple blank line then use this one

Code:
$ awk '{printf (NR > 1 && /EPC-Sub/) ? RS $2 OFS : $2 OFS }END{printf RS} ' file


Last edited by Akshay Hegde; 12-12-2013 at 03:52 AM.. Reason: simplification
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. 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

2. UNIX for Dummies Questions & Answers

Change Vertical to Horizontal

I need to change data from vertical to horizontal but with condition input USA|80 AUS|40 BRA|33 VEGAS|40 KENTUCKY|50 NEWYORK|21 DARWIN|33 ADELAIDE|21 SAOPAOLO|44 RIO|89 GAPIZA|44 BENFLEX|32 AXIS|44 ACRE|56 HEIGHT|22 (5 Replies)
Discussion started by: radius
5 Replies

3. Shell Programming and Scripting

How do i do the vertical to horizontal??

51009 8746 8912 17986 20315 24998 5368 38934 7805 8566 (4 Replies)
Discussion started by: nikhil jain
4 Replies

4. Shell Programming and Scripting

Need perl or shell script to sort vertical lines to horizontal line in csv format

Need perl or shell script to sort vertical lines to horizontal line in csv format My file like below ------------------------- ================================================================================ PATH PINKY1000#I1-1-ZENTA1000-2#I7-1-ASON-SBR-UP-943113845 ... (4 Replies)
Discussion started by: sreedhargouda.h
4 Replies

5. Shell Programming and Scripting

change log vertical to horizontal lines

Hi, Need help unix command to change this : become this Anyone can help me?:wall: (2 Replies)
Discussion started by: justbow
2 Replies

6. 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

7. UNIX for Dummies Questions & Answers

Horizontal to vertical

Hi, Silly question, if I have an excel file that looks something like this: ................. Subject 1 Subject 2 Subject 3 Subject 4 Fever..............13...........9.............23..........14 Headache.........2............12...........18..........23... (3 Replies)
Discussion started by: Xterra
3 Replies

8. Shell Programming and Scripting

Need help in changing vertical lines to horizontal line in a file

Hi, I have a file like below robert PREF: 3 AVAIL: henry PREF: 234 AVAIL: john PREF: 145,178 AVAIL: 123 matt PREF: 564,932 AVAIL: ten PREF: 389 AVAIL: kill (2 Replies)
Discussion started by: rocky1954
2 Replies

9. 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

10. 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