Script: Convert row in to column | 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.

Script: Convert row in to column

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 12-06-2012
elilmal elilmal is offline
Registered User
 
Join Date: Dec 2012
Last Activity: 27 August 2013, 8:27 AM EDT
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Script: Convert row in to column

Hi,

i need to convert


Code:
SG_ERP1
SG_ERP2
SG_ERP3

in to:


Code:
SG_ERP1 SG_ERP2 SG_ERP3

It's possibile?
Sponsored Links
    #2  
Old 12-06-2012
Scott's Avatar
Scott Scott is offline Forum Staff  
Administrator
 
Join Date: Jun 2009
Last Activity: 31 October 2014, 2:30 AM EDT
Location: Zürich
Posts: 8,484
Thanks: 332
Thanked 1,047 Times in 914 Posts
Hi.

Yes, it is possible with the paste command.
Sponsored Links
    #3  
Old 12-06-2012
ryandegreat25 ryandegreat25 is offline
Registered User
 
Join Date: Jul 2009
Last Activity: 27 November 2013, 3:15 AM EST
Posts: 286
Thanks: 16
Thanked 3 Times in 3 Posts
one thing i like is use of cat and echo

Code:
-bash-3.2$ cat test
a
b
c
-bash-3.2$ echo `cat test`
a b c
-bash-3.2$ echo $(cat test)
a b c
-bash-3.2$

    #4  
Old 12-06-2012
itkamaraj's Avatar
itkamaraj itkamaraj is offline Forum Advisor  
^Kamaraj^
 
Join Date: Apr 2010
Last Activity: 3 October 2014, 8:50 AM EDT
Posts: 3,059
Thanks: 33
Thanked 659 Times in 638 Posts

Code:
awk -v ORS=" " '1' input.txt

Sponsored Links
    #5  
Old 12-06-2012
elilmal elilmal is offline
Registered User
 
Join Date: Dec 2012
Last Activity: 27 August 2013, 8:27 AM EDT
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts

Code:
SG_LNX_JOKER_PRE01
SG_LNX_PENGUIN_PRE01
VP_Cattivi_pre01

SG_LNX_JOKER_PRE01
SG_LNX_PENGUIN_PRE01
VP_Cattivi_pre01


it's changed in one row:


Code:
SG_LNX_JOKER_PRE01 SG_LNX_PENGUIN_PRE01 VP_Cattivi_pre01  SG_LNX_JOKER_PRE01 SG_LNX_PENGUIN_PRE01 VP_Cattivi_pre01  SG_LNX_JOKER_PRE01 SG_LNX_PENGUIN_PRE01 VP_Cattivi_pre01

How can i preserve the space from two groups?

Last edited by Scott; 12-06-2012 at 06:54 AM.. Reason: Code tags
Sponsored Links
    #6  
Old 12-06-2012
ryandegreat25 ryandegreat25 is offline
Registered User
 
Join Date: Jul 2009
Last Activity: 27 November 2013, 3:15 AM EST
Posts: 286
Thanks: 16
Thanked 3 Times in 3 Posts
please post the output of what you are trying to accomplish
Sponsored Links
    #7  
Old 12-06-2012
elilmal elilmal is offline
Registered User
 
Join Date: Dec 2012
Last Activity: 27 August 2013, 8:27 AM EDT
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts

Code:
SG_LNX_JOKER_PRE01 SG_LNX_PENGUIN_PRE01 VP_Cattivi_pre01

SG_LNX_JOKER_PRE01 SG_LNX_PENGUIN_PRE01 VP_Cattivi_pre01


Last edited by Scott; 12-06-2012 at 06:54 AM.. Reason: Code tags
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
convert row to column with respect of first column. asavaliya Shell Programming and Scripting 4 09-07-2012 04:34 PM
Convert column data to row data using shell script sktkpl UNIX for Advanced & Expert Users 4 06-06-2012 05:55 AM
Convert row to column gvj Shell Programming and Scripting 1 10-20-2011 10:59 AM
column to row convert - script - help G0Y Shell Programming and Scripting 10 11-14-2008 04:12 AM
convert column into row with some modifier cdfd123 UNIX for Dummies Questions & Answers 1 07-10-2008 03:23 AM



All times are GMT -4. The time now is 05:47 AM.