Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting


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

Reply    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 03-01-2013
Registered User
 
Join Date: Apr 2011
Location: Bangalore
Posts: 98
Thanks: 24
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
Moderator
 
Join Date: Nov 2008
Location: Amsterdam
Posts: 7,804
Thanks: 147
Thanked 1,770 Times in 1,607 Posts
How about:

Code:
xargs -n7 < file

The Following 2 Users Say Thank You to Scrutinizer For This Useful Post:
panyam (03-01-2013), Yoda (03-01-2013)
Sponsored Links
    #3  
Old 03-01-2013
panyam panyam is offline Forum Advisor  
Registered User
 
Join Date: Sep 2008
Posts: 1,141
Thanks: 20
Thanked 101 Times in 96 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
Moderator
 
Join Date: Nov 2008
Location: Amsterdam
Posts: 7,804
Thanks: 147
Thanked 1,770 Times in 1,607 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
Jedi Master
 
Join Date: Jan 2012
Location: Galactic Empire
Posts: 2,490
Thanks: 166
Thanked 810 Times in 779 Posts
Another approach:

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

Sponsored Links
Reply

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 02:17 AM.