Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
Help search and replace
Name: gpatel Date: April 29, 2005 at 06:26:53 Pacific OS: UNIX CPU/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
Name: gpatel Date: April 29, 2005 at 08:32:16 Pacific
Reply:
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
0
Response Number 2
Name: nails Date: April 29, 2005 at 08:47:21 Pacific
Reply:
What do you need an if statement for:
sed -e 's/red/1/g' -e 's/blue/2/g' -e 's/black/3/g'
0
Response Number 3
Name: Luke Chi Date: April 29, 2005 at 09:04:39 Pacific
Reply:
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
0
Response Number 4
Name: gpatel Date: April 29, 2005 at 10:36:49 Pacific
Reply:
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
0
Response Number 5
Name: gpatel Date: April 29, 2005 at 10:38:52 Pacific
Reply:
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
Summary: Hi, I intend to do a search and replace for specific words for files under a directory (inclusive of subdirectories). I know how to do that file by file using sed and redirect it to the original file....
Summary: Hi, Can anyone help me with the command to do the following search and replace in the following files: Files: file1 file2 file3 Search String: "GET /thisfile?id= Replace String: "GET /thisfile?source=...
Summary: Is it possible to do search and replace in unix Like : s/some date/current date/g some date and current date both are in same format (dd/mm/yyyy hh:mm:ss) My requirement is : I am having a variable w...