Visit Our UNIX and Linux User Community

[SOLVED] splitting a single column(with spaces) into multiple rows

Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers [SOLVED] splitting a single column(with spaces) into multiple rows
# 1  
Old 09-20-2012
Computer [SOLVED] splitting a single column(with spaces) into multiple rows

Hi All,
My requisite is to split a single column of phonemes seperated by spaces into multiple rows.
my input file is:


my o/p should be like:

adhu                      a dh u 
thaqnchAvUrk      th a qn ch A v U r k

please make sure that the code should work in TCSH.

Last edited by Scrutinizer; 09-20-2012 at 08:07 AM.. Reason: code tags
# 2  
Old 09-20-2012
Like this?
awk '{t=$0;gsub(/\n/,"",$0);gsub(/\n/," ",t);print $0,t}' RS= file

# 3  
Old 09-20-2012
Small variation:
awk '{$1=$1; p=$0; gsub(FS,x); print $0,p}' RS= file

# 4  
Old 09-21-2012
Thanks a lot....
The two codes worked out wellSmilie

---------- Post updated at 11:15 PM ---------- Previous update was at 12:21 PM ----------

i have one more doubt regarding this.
the same input file filled with silence instead of white space,i used the simple print command to get the o/p mentioned above.but am not getting.the code is

if ("$a" == "sil") then  #a is the input file
echo "\n"
printf "%s" "$a"
printf "%s " "$a"

i know that printf "%s" "$a" gives :adhu
and printf "%s " "$a" gives :a dh u
but i dono how to make it as :adhu a dh u
this may be silly...anyway i need help.

Last edited by Scrutinizer; 09-21-2012 at 04:53 AM.. Reason: code tags

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Splitting single row into multiple rows based on for every 10 digits of last field of the row

Hi ALL, We have requirement in a file, i have multiple rows. Example below: Input file rows 01,1,102319,0,0,70,26,U,1,331,000000113200000011920000001212 01,1,102319,0,1,80,20,U,1,241,00000059420000006021 I need my output file should be as mentioned below. Last field should split for... (4 Replies)
Discussion started by: kotra
4 Replies

2. Shell Programming and Scripting

Converting Single Column into Multiple rows

Hi .. anyone can you help me ? i need to convert text below into multiple columns interface; GigabitEthernet0/0/0/0 description; TRUNK_PE-D2-JT2-VPN_Gi0/0/0/0_TO_ME4-A-JKT-JT_4/1/1_1G mtu 9212 negotiation auto interface; GigabitEthernet0/0/0/0.11 description; tes encapsulation;... (1 Reply)
Discussion started by: mad3linux
1 Replies

3. Shell Programming and Scripting

Convert single column into multiple rows

Convert Single column to multiple rows file a.txt contains data like below Server=abc Run=1 Tables=10 Sessions=16 Time=380 Jobs=5 Server=abc Run=2 Tables=15 Sessions=16 Time=400 Jobs=5 Server=abc Run=3 Tables=20 Sessions=16 Time=450 (5 Replies)
Discussion started by: sol_nov
5 Replies

4. Shell Programming and Scripting

Converting Single Column into Multiple rows, but with strings to specific tab column

Dear fellows, I need your help. I'm trying to write a script to convert a single column into multiple rows. But it need to recognize the beginning of the string and set it to its specific Column number. Each Line (loop) begins with digit (RANGE). At this moment it's kind of working, but it... (6 Replies)
Discussion started by: AK47
6 Replies

5. Shell Programming and Scripting

Transpose multiple rows (with a mix of space and enter) to a single column

How to change the uploaded weekly file data to the following format? New Well_Id,Old Well_Id,District,Thana,Date,Data,R.L,WellType,Lati.,Longi. BAG001,PT006,BARGUNA,AMTALI,1/2/1978,1.81,2.29,Piezometer,220825,901430 BAG001,PT006,BARGUNA,AMTALI,1/9/1978,1.87,2.29,Piezometer,220825,901430... (3 Replies)
Discussion started by: sara.nowreen
3 Replies

6. Shell Programming and Scripting

How to merge multiple rows into single row if first column matches ?

Hi, Can anyone suggest quick way to get desired output? Sample input file content: A 12 9 A -0.3 2.3 B 1.0 -4 C 34 1000 C -111 900 C 99 0.09 Output required: A 12 9 -0.3 2.3 B 1.0 -4 C 34 1000 -111 900 99 0.09 Thanks (3 Replies)
Discussion started by: cbm_000
3 Replies

7. Shell Programming and Scripting

Split single rows to multiple rows ..

Hi pls help me out to short out this problem rm PAB113_011.out rm: PAB113_011.out: override protection 644 (yes/no)? n If i give y it remove the file. But i added the rm command as a part of ksh file and i tried to remove the file. Its not removing and the the file prompting as... (7 Replies)
Discussion started by: sri_aue
7 Replies

8. Shell Programming and Scripting

Single column into multiple rows

Hi all, I need to convert this file having just one column into two column file current file: a 15 b 21 c 34 d 48 e 10 wanted: a 15 b 21 c 34 (15 Replies)
Discussion started by: prachiagra
15 Replies

9. Shell Programming and Scripting

Converting Single Column into Multiple rows

i have single column which is starting with same string(many number of rows) i have to convert each into a single can i do that? laknar std mes 23 55 laknar isd phone no address amount 99 I have to convert above like below. laknar|std|mes|23|55 laknar|isd|phone... (3 Replies)
Discussion started by: laknar
3 Replies

10. UNIX for Dummies Questions & Answers

splitting a column into rows

I have a column of data of the format: EDITORIAL OPED 193987141 193986701 193987451 193986321 STATISTICS 193986351 COLUMN EDITORIAL OPED 193987171 NEWS 193321171 NEWS 193321111 NEWS 193320891 NEWS 193321841 (3 Replies)
Discussion started by: spindoctor
3 Replies

Featured Tech Videos