Separator in data itself


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Separator in data itself
# 1  
Old 06-17-2008
Separator in data itself

Following is the CSV file, separated by ","
Code:
100,sunil,$1,000,mumbai
101,amit,$10,000,mumbai
102,sailesh,$10,000,00,mumbai

I want the following output:
Code:
100,sunil,$1000,mumbai
101,amit,$10000,mumbai
102,sailesh,$1000000,mumbai

Note: I know the number of fields in the file in advance. In this case it is 4.

Any help is highly appreciated.


Thanks,
SK

Last edited by Yogesh Sawant; 06-17-2008 at 08:39 AM.. Reason: added code tags
# 2  
Old 06-17-2008
Code:
sed "s/\([0-9]\),\([0-9]\)/\1\2/g" input_file.txt

# 3  
Old 06-17-2008
using Perl:
Code:
perl -pi -e 's/(\d),(\d)/\1\2/g' filename

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Separator

Hello everybody, I'll get one more help I have a cabundle file that I need to separate into 2 parts, the first sequence and the second sequence, I thought of several things but I did not remember anything that could actually accomplish this separation and transform into 2 variables, first... (4 Replies)
Discussion started by: c0i0t3
4 Replies

2. Shell Programming and Scripting

Field separator

Hello All, I have a file, but I want to separate the file at a particular record with comma"," in the line Input file APPLE6SSAMSUNGS5PRICEPERPIECEDOLLAR600EACH010020340URX581949695US to Output file APPLE6S,SAMSUNGS5,PRICEPERPIECE,DOLLAR600EACH,010020340URX581949695,US This is for... (11 Replies)
Discussion started by: m6248m
11 Replies

3. Shell Programming and Scripting

Row separator

Hello All, I need help with the below, I would appreciate any tip. I have a file as below Input file Apple: Green Banana: Yellow Grapes: Black Apple: Red Banana: Green Grapes: Green Grapes: Brown Apple: Pale Red Banana: Greenish yellow Grapes: Brown Apple: Yellowish... (14 Replies)
Discussion started by: m6248m
14 Replies

4. Shell Programming and Scripting

row separator with RS

I have a file contains lines such as below: HRS ? ? ? Pg ? 20120811 1223 19.6 GAU 1.00e-01 0.00e-01 0.00e-01 0.00e-01 TBZ ? ? ? Pg ? 20120811 1223 26.2 GAU 1.00e-01 0.00e-01 0.00e-01 0.00e-01 ### HRS ? ? ? Pg ? 20120811 1228 52.2 GAU 1.00e-01 0.00e-01 0.00e-01 0.00e-01 ### ... (4 Replies)
Discussion started by: saeed.soltani
4 Replies

5. Shell Programming and Scripting

Field separator X'1F'

Hi, I have a flat file with fields separated by a X'1F' i have to fetch 4th field from second line. please help me how to achieve it. I tried with below command and its not working. cut -f4 -d`echo -e '\x1f'` filename.txt I am using SunOS. Thanks in advance. (2 Replies)
Discussion started by: rohan10k
2 Replies

6. Shell Programming and Scripting

Using > as record separator

I have tried to use ">" as record separator, but it doesn't work. I have tried this: awk BEGIN{RS=">"}'{print $0}' input output: awk: BEGIN{RS=>}{print $0} awk: ^ syntax error awk BEGIN{RS="\>"}'{print $0}' input awk: BEGIN{RS=\>}{print $0} awk: ^ backslash not... (2 Replies)
Discussion started by: locoroco
2 Replies

7. Shell Programming and Scripting

how to handle , in data where separator also commas in awk script

TEST_HEME,"SubNetwork=ONRM_RootMoR,SubNetwork=ARNC1",CELL when I split by FS="," then $0=TEST_HEME $1="SubNetwork=ONRM_RootMoR $2=SubNetwork=ARNC1" but I need this will be single value "SubNetwork=ONRM_RootMoR,SubNetwork=ARNC1" (4 Replies)
Discussion started by: Hemendra
4 Replies

8. Shell Programming and Scripting

Perl: Separator

Hello all, I'm trying to break down a file with the following format: entries dzdf daff enries dfln fnljfd . . .. . I'm reading this file, using "[" as my separator. It's working quite well, but I would like to be able to read the "[" character into my array as a valid... (4 Replies)
Discussion started by: Khoomfire
4 Replies

9. Shell Programming and Scripting

record separator

can anyone tell me any way to change record separator (default is new line). RS in nawk as not working. Thanks in advance. Regards Rochit (7 Replies)
Discussion started by: rochitsharma
7 Replies

10. Shell Programming and Scripting

Separator in Makefile?

all: $(LIBRARY) $(EXE) $(MAKEMAKE): @rm -f $(MAKEMAKE) $(PURIFY) $(CXX) -M $(INCLUDE) $(CPPFLAGS) *.cpp > $(MAKEMAKE) $(EXE): $(OBJS) $(LIBRARY) @echo "Creating a executable " $(PURIFY) $(CC) -o $(EXE) $(OBJS) $(ALLLDFLAGS) $(LIBS) This is a snippet... (2 Replies)
Discussion started by: laila63
2 Replies
Login or Register to Ask a Question