Unix/Linux Go Back    


Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

How do i do the vertical to horizontal??

Shell Programming and Scripting


Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 03-01-2013
nikhil jain nikhil jain is offline
Registered User
 
Join Date: Apr 2011
Last Activity: 25 April 2017, 1:13 AM EDT
Location: Bangalore
Posts: 169
Thanks: 37
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 Unix and Linux 03-01-2013
Scrutinizer's Unix or Linux Image
Scrutinizer Scrutinizer is offline Forum Staff  
Moderator
 
Join Date: Nov 2008
Last Activity: 26 April 2017, 1:19 AM EDT
Location: Amsterdam
Posts: 11,400
Thanks: 487
Thanked 3,276 Times in 2,891 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 Unix and Linux 03-01-2013
panyam panyam is offline Forum Advisor  
Registered User
 
Join Date: Sep 2008
Last Activity: 13 April 2017, 4:34 AM EDT
Posts: 1,160
Thanks: 20
Thanked 105 Times in 100 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 Unix and Linux 03-01-2013
Scrutinizer's Unix or Linux Image
Scrutinizer Scrutinizer is offline Forum Staff  
Moderator
 
Join Date: Nov 2008
Last Activity: 26 April 2017, 1:19 AM EDT
Location: Amsterdam
Posts: 11,400
Thanks: 487
Thanked 3,276 Times in 2,891 Posts
Another ( awkish Linux ) 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 Unix and Linux 03-01-2013
Yoda's Unix or Linux Image
Yoda Yoda is offline Forum Advisor  
Jedi Master
 
Join Date: Jan 2012
Last Activity: 19 April 2017, 12:51 PM EDT
Location: Galactic Empire
Posts: 3,539
Thanks: 251
Thanked 1,288 Times in 1,210 Posts
Another approach:

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

Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux 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 03:58 AM.