command for converting 4 column data to 1 column


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting command for converting 4 column data to 1 column
# 1  
Old 12-11-2011
command for converting 4 column data to 1 column

dear friends I want to convert four column data to one column data. For example:

from
Code:
1, 2, 3, 4
5, 6, 7, 8

to
Code:
1
2
3
4
5
6
7
8

what is the general command for that type of convertion.

thanks

Last edited by zxmaus; 12-11-2011 at 11:50 PM.. Reason: added tags
# 2  
Old 12-11-2011
Code:
sed 's/, /\n/g' file

This User Gave Thanks to bartus11 For This Post:
# 3  
Old 12-11-2011
Code:
tr ',' '\n' < filename


Last edited by zxmaus; 12-11-2011 at 11:49 PM.. Reason: added code tags
This User Gave Thanks to tarun_agrawal For This Post:
# 4  
Old 12-12-2011
Try this

Code:
cat file.txt |tr  ',' '\n' | tr -d ' '

This User Gave Thanks to palanisvr For This Post:
# 5  
Old 12-12-2011
Or even (getting rid of the space characters first):
Code:
sed -e "s/ //g" filename | tr ',' '\n'

# 6  
Old 12-12-2011
The Perl way Smilie

Code:
perl -pe 's/, /\n/g' filename

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to insert data into black column( Secound Column ) in excel (.XLSX) file using shell script?

Source Code of the original script is down below please run the script and try to solve this problem this is my data and I want it column wise 2019-03-20 13:00:00:000 2019-03-20 15:00:00:000 1 Operating System LAB 0 1 1 1 1 1 1 1 1 1 0 1 (5 Replies)
Discussion started by: Shubham1182
5 Replies

2. Shell Programming and Scripting

Split column data if the table has n number of column's with some record

Split column data if the table has n number of column's with some record then how to split n number of colmn's line by line with records Table --------- Col1 col2 col3 col4 ....................col20 1 2 3 4 .................... 20 a b c d .................... v ... (11 Replies)
Discussion started by: Priti2277
11 Replies

3. Shell Programming and Scripting

Using loop command in UNIX for converting column to row

Dear folks I have 300 files which one of them are looking like: 1.SNP 0 0 1 0 I am looking for desire output: 1.SNP 0 0 1 0 I used this below command to run all of the 300 file at the same time for file in *.SNP; do awk '{printf( "%s ", $1 );} END {printf("\n");}' $file >... (1 Reply)
Discussion started by: sajmar
1 Replies

4. Shell Programming and Scripting

Insert data in first column(if blank) from previous line first column

Dear Team I need to insert field(which is need to taken from previous line's first field) in first column if its blank. I had tried using sed but not find the way. Detail input and output file as below. Kindly help for same. INPUT: SCGR SC DEV DEV1 NUMDEV DCP ... (7 Replies)
Discussion started by: jaydeep_sadaria
7 Replies

5. 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

6. Shell Programming and Scripting

Compare 2 files and match column data and align data from 3 column

Hello experts, Please help me in achieving this in an easier way possible. I have 2 csv files with following data: File1 08/23/2012 12:35:47,JOB_5330 08/23/2012 12:35:47,JOB_5330 08/23/2012 12:36:09,JOB_5340 08/23/2012 12:36:14,JOB_5340 08/23/2012 12:36:22,JOB_5350 08/23/2012... (5 Replies)
Discussion started by: asnandhakumar
5 Replies

7. UNIX for Dummies Questions & Answers

Converting column to rows for every 3 lines in the column

Hi gurus! Please help me with this one. I have an file with the following contents: a b c d e f g h i j I would like to make to transform it to look like this as my output file: a,b,c d,e,f (4 Replies)
Discussion started by: kokoro
4 Replies

8. Shell Programming and Scripting

Replace column that matches specific pattern, with column data from another file

Can anyone please help with this? I have 2 files as given below. If 2nd column of file1 has pattern foo1@a, find the matching 1st column in file2 & replace 2nd column of file1 with file2's value. file1 abc_1 foo1@a .... abc_1 soo2@a ... def_2 soo2@a .... def_2 foo1@a ........ (7 Replies)
Discussion started by: prashali
7 Replies

9. Shell Programming and Scripting

row to column and position data in to fixed column width

Dear friends, Below is my program and current output. I wish to have 3 or 4 column output in order to accomodate in single page. i do have subsequent command to process after user enter the number. Program COUNT=1 for MYDIR in `ls /` do VOBS=${MYDIR} echo "${COUNT}. ${MYDIR}" ... (4 Replies)
Discussion started by: baluchen
4 Replies

10. Windows & DOS: Issues & Discussions

Split Data in one column into 2 column in Excel using DOS or VBScript

Hi I have some data in my Excel File.However all the data is in one single column.I want to split it into two columns. Current Data: 1,Hi Everyone,I am 7,New To Dos,And 17,VB Script,i could 110,have tried this thing 1800,in UNIX Desired Output CELL1|CELL 2 1 |Hi... (3 Replies)
Discussion started by: dashing201
3 Replies
Login or Register to Ask a Question