How do i do the vertical to horizontal?? | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

How do i do the vertical to horizontal??

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 03-01-2013
nikhil jain nikhil jain is offline
Registered User
 
Join Date: Apr 2011
Last Activity: 16 September 2014, 4:07 AM EDT
Location: Bangalore
Posts: 114
Thanks: 25
Thanked 2 Times in 2 Posts
How do i do the vertical to horizontal??


Code:
Code:
51009

8746

8912

17986

20315

24998

5368

38934

7805

8566

9993

14998

24996

5318

35254

5747

5999

7000

15000

25000

0

I want the above o/p to be in row wise...
every row shul hav 7 colmuns oly...
Sponsored Links
    #2  
Old 03-01-2013
Scrutinizer's Avatar
Scrutinizer Scrutinizer is offline Forum Staff  
Moderator
 
Join Date: Nov 2008
Last Activity: 21 September 2014, 11:34 PM EDT
Location: Amsterdam
Posts: 9,465
Thanks: 279
Thanked 2,388 Times in 2,140 Posts
How about:

Code:
xargs -n7 < file

The Following 3 Users Say Thank You to Scrutinizer For This Useful Post:
panyam (03-01-2013), RavinderSingh13 (11-22-2013), Yoda (03-01-2013)
Sponsored Links
    #3  
Old 03-01-2013
panyam panyam is offline Forum Advisor  
Registered User
 
Join Date: Sep 2008
Last Activity: 24 July 2014, 3:48 AM EDT
Posts: 1,156
Thanks: 20
Thanked 104 Times in 99 Posts

Code:
sed '/^$/d' file |   awk 'NR%7!=0 {a=a>0?a OFS $1:$1;next} { print a OFS $1;a=""}' OFS=","

    #4  
Old 03-01-2013
Scrutinizer's Avatar
Scrutinizer Scrutinizer is offline Forum Staff  
Moderator
 
Join Date: Nov 2008
Last Activity: 21 September 2014, 11:34 PM EDT
Location: Amsterdam
Posts: 9,465
Thanks: 279
Thanked 2,388 Times in 2,140 Posts
Another ( awkish ) awk:

Code:
awk 'NF && ORS=++i%7?FS:RS' file

The Following User Says Thank You to Scrutinizer For This Useful Post:
panyam (03-01-2013)
Sponsored Links
    #5  
Old 03-01-2013
Yoda's Avatar
Yoda Yoda is offline Forum Advisor  
Jedi Master
 
Join Date: Jan 2012
Last Activity: 19 September 2014, 1:56 PM EDT
Location: Galactic Empire
Posts: 3,383
Thanks: 234
Thanked 1,208 Times in 1,134 Posts
Another approach:

Code:
grep -v '^$' file | paste - - - - - - -

Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
awk in horizontal and vertical math busyboy Shell Programming and Scripting 6 02-15-2013 02:37 AM
Vertical And Horizontal Pivoting kmsekhar Shell Programming and Scripting 3 02-01-2012 06:32 AM
vertical to horizontal andrisetia UNIX for Dummies Questions & Answers 6 10-03-2011 06:03 AM
Horizontal to vertical Xterra UNIX for Dummies Questions & Answers 3 09-09-2011 11:54 AM
combine files in horizontal way, not vertical. jimmy_y Shell Programming and Scripting 3 10-29-2009 05:10 AM



All times are GMT -4. The time now is 08:11 AM.