Visit Our UNIX and Linux User Community


Editing Commas in a textfile using sed


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Editing Commas in a textfile using sed
# 8  
Old 09-10-2009
The 'solution' was presented for a given SAMPLE file format - YMMV for other 'formats'.
# 9  
Old 09-11-2009
different input
Could you plz suggest modification
How could I modify the code for this kind of input

Code:
7829885 7831552 + 1    1667,               0,
35934936 35937087 - 2  1281,870,       0,1281, 120000, 1444444,1111, 333333333 , 2222, 44444, 6666666 ,  555555
35934936 35937087 - 2  1281, 870,      0 ,1281 ,
35934936 35937087 - 2  1281 , 870 ,    0, 1281 ,



---------- Post updated at 07:40 PM ---------- Previous update was at 07:37 PM ----------

I mean what if the column has multiple values (occurences) with commas
# 10  
Old 09-11-2009
what's the desired output given that sample input?
# 11  
Old 09-11-2009
Desired output

Code:
7829885 7831552 + 1    1667               0
35934936 35937087 - 2  1281,870       0,1281,120000,1444444,1111,333333333,2222,44444,6666666,555555
35934936 35937087 - 2  1281,870      0,128
35934936 35937087 - 2  1281,870    0,1281

I think your previous code is working fine with this kind of problem. But if I'm trying to open the result in excel file the values are looking some thing like this in some parts. However the output looking fine in notepad or word pad. I dontknow the reason why.

Code:
7829885 7831552 + 1    1667               0
35934936 35937087 - 2  1,281,870       0,1,281120,000144,4444,11113333,33333,222244444,66666,66555555
35934936 35937087 - 2  1,281,870      0,128
35934936 35937087 - 2  1,281,870    0,1281

# 12  
Old 09-11-2009
don't know why........

Last edited by vgersh99; 09-11-2009 at 10:56 AM..
# 13  
Old 09-11-2009
But i want the same values that i can see in word or notepad in excel. I tried but couldn't able to fugured out. Do you have any idea.

Previous Thread | Next Thread
Test Your Knowledge in Computers #964
Difficulty: Medium
HTML4 became a W3C Recommendation in 1994.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to separate sorte different characters from one textfile and copy them in a new textfile?

My first post, so don't kill me :) Say i open some textfile with some example like this. on the table are handy, bread and wine Now i know exactly what is in and i want to separate and sorted it in terminal to an existing file with another 2 existing lines in like this: table plane ... (3 Replies)
Discussion started by: schwatter
3 Replies

2. Shell Programming and Scripting

HELP with AWK or SED. Need to replace the commas between double quotes in CSV file

Hello experts, I need to validate a csv file which contains data like this: Sample.csv "ABCD","I",23,0,9,,"23/12/2012","OK","Street,State, 91135",0 "ABCD","I",23,0,9,,"23/12/2012","OK","Street,State, 91135",0 I just need to check if all the records contain exactly the number of... (5 Replies)
Discussion started by: shell_boy23
5 Replies

3. UNIX for Dummies Questions & Answers

sed help finding and editing

With sed 1. I need to find a line that contains "DVM" and "73069". 2. I need to insert a double quote at the beginning of the first line of the file. These two have been driving me crazy for the last 45 minutes. Any help would be greatly appreciated. Thanks (3 Replies)
Discussion started by: nlassiter
3 Replies

4. Windows & DOS: Issues & Discussions

Extracting variables between commas : GAWK or SED

Hello, I need some help, I got a CSV file called test.txt with this text in it : 08/02/2011;0,677;0,903;1,079;1,336;1,513;1,683 There's only a line and i need to copy theese numbers into variables : 0,677 0,903 1,079 1,336 1,513 1,683 The output file should look like this... (5 Replies)
Discussion started by: jujulips
5 Replies

5. UNIX for Dummies Questions & Answers

sed editing help....

Hello all, I need some help with sed. seems like i cant get through it. So here is what i am trying. when i do ps -ef|grep bla blah ...like below...i get /u01/app/oracle/11g/bin/tnslsnr .... but i want to replace that string with something using sed. So basically i want to get rid of... (3 Replies)
Discussion started by: abdul.irfan2
3 Replies

6. Shell Programming and Scripting

sed or awk editing help

Hi all I use aix (sadly). I've got a file consisting of fields separated by commas, I need a sed or awk command that will delete all spaces between two commas as long as there are only spaces between the commas. eg ,abc, ,sd , ,dr at would become ,abc,,sd ,,dr at I have... (53 Replies)
Discussion started by: mychmose
53 Replies

7. Shell Programming and Scripting

Help with sed and replacing white spaces with commas

Dear all, I am in a bit of a quandary. I have 400 text files which I need to edit and output in a very specific way. Here is a sample text file copied from gedit ... The columns will come out a bit messed up but when I cat <file>, it gives a table with six columns (0-28, tot lob vol, vcsf,... (6 Replies)
Discussion started by: antonz
6 Replies

8. Homework & Coursework Questions

String editing using sed? awk?

1. The problem statement, all variables and given/known data: Problem Statement for project: When an account is created on the CS Unix network, a public html directory is created in the account's home directory. A default web page is put into that directory. Some users replace or... (13 Replies)
Discussion started by: peage1475
13 Replies

9. UNIX for Dummies Questions & Answers

Inserting commas and replacing backslashes with commas

Hi, Newbie here. I have a file that consists of data that I want to convert to a csv file. For example: Jul 20 2008 1111 / visit home / BlackBerry8830/4.2.2 Profile/MIDP-2.0 Configuration/CLOC-1.1 VendorID/105 Jul 21 2008 22222 / add friend / BlackBerry8830/4.2.2 Profile/MIDP-2.0... (3 Replies)
Discussion started by: kangaroo
3 Replies

10. Shell Programming and Scripting

Editing File using awk/sed

Hello Awk Gurus, Can anyone of you help me with the below problem. I have got a file having data in below format pmFaultyTransportBlocks ----------------------- 9842993 pmFrmNoOfDiscRachFrames ----------------------- NULL pmNoRecRandomAccSuccess -----------------------... (4 Replies)
Discussion started by: Mohammed
4 Replies

Featured Tech Videos