Search and replace error


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Search and replace error
# 1  
Old 02-20-2009
Search and replace error

Hi,

I need a command to search and replace the string, dlp040 to mld200 in multiple html files. I used the following command but it doesnt work

sed s/"dlp040 "/"mld200 "/g *

Please help,

Thanks
# 2  
Old 02-20-2009
Does you input file have the double quotes in it?
# 3  
Old 02-20-2009
Hi,

I need a command to search and replace the string, dlp040 to mld200 in multiple html files. I used the following command but it doesnt work

sed s/"dlp040 "/"mld200 "/g *
HTML Code:
basically in the HTML FILES it is <!--dlp040--> which should be replaced by <!--mld200-->

Please help,

Thanks
# 4  
Old 02-20-2009
Then take the quotes off your prior sed command. It will work if you do this:
Code:
sed 's/dlp400/mld200/g' inputfile > outputfile

but I do not know how or if you can modify the input file in one sed command.

Something like this might work though:
Code:
for f in `ls *.html `
do
   sed 's/dlp400/mld200/g' $f > $f.new
   mv $f.new $f
done

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Nested search in a file and replace the inner search

Hi Team, I am new to unix, please help me in this. I have a file named properties. The content of the file is : ##Mobile props east.url=https://qa.east.corp.com/prop/end west.url=https://qa.west.corp.com/prop/end south.url=https://qa.south.corp.com/prop/end... (2 Replies)
Discussion started by: tolearn
2 Replies

2. Shell Programming and Scripting

Search and replace error using sed

Hi, Basically , i search for a string ( from variable) in a input file , if line found then search a string called "STRING" and replace with text (from another variable ). I cant avoid # delimiter due to esc sequences. #!/bin/bash LINE="source/path" REPLACE="TEXT/TO/REPLACE" sed -e... (9 Replies)
Discussion started by: greet_sed
9 Replies

3. UNIX for Dummies Questions & Answers

Help with search and replace or search only of / in vi

Hi all, I am editing a config file in vi that has a / on it. At the moment, search and replace looks alright as am able to use a # as a temporary separator, i.e. :,$s#/u01/app#/u02/app#g For doing a search, I have to escape the / do. So if I want to search for /u01/app, I am having to do... (2 Replies)
Discussion started by: newbie_01
2 Replies

4. Shell Programming and Scripting

perl search and replace - search in first line and replance in 2nd line

Dear All, i want to search particular string and want to replance next line value. following is the test file. search string is tmp,??? ,10:1 "???" may contain any 3 character it should remain the same and next line replace with ,10:50 tmp,123 --- if match tmp,??? then... (3 Replies)
Discussion started by: arvindng
3 Replies

5. Shell Programming and Scripting

search and replace

Hi, I am having trouble with searching for a name and replacing it. The file is tab deliminated. Basically I want to replace >ref|NC_001147| and >ref|NC_001148| with chr1 and chr2 respectively. Here is what my file looks like: >1_1_120_317 S OXTGHFKDK ... (2 Replies)
Discussion started by: phil_heath
2 Replies

6. Shell Programming and Scripting

awk - replace number of string length from search and replace for a serialized array

Hello, I really would appreciate some help with a bash script for some string manipulation on an SQL dump: I'd like to be able to rename "sites/WHATEVER/files" to "sites/SOMETHINGELSE/files" within the sql dump. This is quite easy with sed: sed -e... (1 Reply)
Discussion started by: otrotipo
1 Replies

7. Shell Programming and Scripting

Search and replace

I have a script which has several occurences of statement like command: $UCMDPATH/xyz abc I would like to replace the entire line starting from $UCMDPATH with the ls -ltr command eg: Prior to change:: command: $UCMDPATH/xyz abc After change: command: ls -ltr Is there a way to do... (12 Replies)
Discussion started by: jobbyjoseph
12 Replies

8. Shell Programming and Scripting

Search and replace

Hi, I have a file that looks like the following: M00071.null T 12 13 1 0 0 SMALL M00074.null T 1 15 14 0 0 0 SMALL M14870.null T 2 15431 15 17 0 1 0 SMALL I want to edit it such that it looks like the following: M00071 12 13 1 0 0 SMALL M00074 (5 Replies)
Discussion started by: mjoshi
5 Replies

9. Shell Programming and Scripting

Perl: Search for string on line then search and replace text

Hi All, I have a file that I need to be able to find a pattern match on a line, search that line for a text pattern, and replace that text. An example of 4 lines in my file is: 1. MatchText_randomNumberOfText moreData ReplaceMe moreData 2. MatchText_randomNumberOfText moreData moreData... (4 Replies)
Discussion started by: Crypto
4 Replies

10. UNIX for Advanced & Expert Users

search and Replace

hello, How to search a Word in a shell file and if that exists echo that the word exists and stop that operation and if that doesn't exists then echo word not found. Thanks in advance. Bye (4 Replies)
Discussion started by: mukeshannamalai
4 Replies
Login or Register to Ask a Question