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: 4 December 2016, 12:30 AM EST
Location: Bangalore
Posts: 163
Thanks: 35
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: 5 December 2016, 2:45 PM EST
Location: Amsterdam
Posts: 11,102
Thanks: 440
Thanked 3,109 Times in 2,750 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: 1 February 2016, 7:31 AM EST
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: 5 December 2016, 2:45 PM EST
Location: Amsterdam
Posts: 11,102
Thanks: 440
Thanked 3,109 Times in 2,750 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: 5 December 2016, 4:51 PM EST
Location: Galactic Empire
Posts: 3,529
Thanks: 248
Thanked 1,281 Times in 1,203 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 03:37 AM
Vertical And Horizontal Pivoting kmsekhar Shell Programming and Scripting 3 02-01-2012 07:32 AM
vertical to horizontal andrisetia UNIX for Dummies Questions & Answers 6 10-03-2011 07:03 AM
Horizontal to vertical Xterra UNIX for Dummies Questions & Answers 3 09-09-2011 12:54 PM
combine files in horizontal way, not vertical. jimmy_y Shell Programming and Scripting 3 10-29-2009 06:10 AM



All times are GMT -4. The time now is 10:51 PM.