Help search and replace
|
Original Message
|
Name: gpatel
Date: April 29, 2005 at 06:26:53 Pacific
Subject: Help search and replaceOS: UNIXCPU/Ram: 512 |
Comment: I am working w/ this huge matrix file. Now in this matrix file 2nd column is strings. lets say its contain red, blue, black. now i can not load this file in matlab. so i wanted to change red to 1 blue to 2 and black to 3. Is there any eaiser way instand of find an replace. As i said this is a huge file so it will take lot of time if i do search and replace. can someone please help me write a scipts or something. i am using unix so you could also use unix command. thanks a lot Gpatel thanks, Gaurav
Report Offensive Message For Removal
|
|
Response Number 1
|
Name: gpatel
Date: April 29, 2005 at 08:32:16 Pacific
Subject: Help search and replace |
Reply: (edit)i have got this a little bit this is what i found out in unix using sed sed -e 's/red/1/g' filename.txt > filename.new.txt now someone please help me with If and else statement thanks, Gaurav
Report Offensive Follow Up For Removal
|
|
Response Number 2
|
Name: nails
Date: April 29, 2005 at 08:47:21 Pacific
Subject: Help search and replace |
Reply: (edit)What do you need an if statement for: sed -e 's/red/1/g' -e 's/blue/2/g' -e 's/black/3/g'
Report Offensive Follow Up For Removal
|
|
Response Number 3
|
Name: Luke Chi
Date: April 29, 2005 at 09:04:39 Pacific
Subject: Help search and replace |
Reply: (edit)Not sure about your file format. Assuming: column_value1 column_value_2 column_value3 ... Script: sed -e 's/ red / 1 /' -e 's/ blue / 2 /' -e 's/ black / 3 /' <your file> Luke Chi
Report Offensive Follow Up For Removal
|
|
Response Number 4
|
Name: gpatel
Date: April 29, 2005 at 10:36:49 Pacific
Subject: Help search and replace |
Reply: (edit)sorry, this is the first time i am using UNIX and i am loving it. I will be doing this for rest of my life. so need to learn fast. thanks a lot guys. i needed a script b/c i do this more than one time. i need to load all the data in matlab and simulate it. but this will work thanks AGAIN. thanks, Gaurav
Report Offensive Follow Up For Removal
|
|
Response Number 5
|
Name: gpatel
Date: April 29, 2005 at 10:38:52 Pacific
Subject: Help search and replace |
Reply: (edit)P.S. I was talking about if and elst statements b/c sometimes there is no red in file. or there is no blue. again thanks a lot for your help thanks, Gaurav
Report Offensive Follow Up For Removal
|
Use following form to reply to current message: