problem with replacing using script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting problem with replacing using script
# 1  
Old 01-09-2009
problem with replacing using script

Hi,

I'm using MKS tool kit to execute a unix script on windows.I'm trying to replace a word in a file.

I'm using sed 's/word/$replaceword/g' $OutputFile

This is not working.Please advice where i'm wrong.

thanks
# 2  
Old 01-09-2009
Code:
sed "s/word/$replaceword/g" $OutputFile

# 3  
Old 01-09-2009
Data

HI,

It is not working.It has not replaced.
# 4  
Old 01-09-2009
Code:
sed "s/word/$replaceword/g" $OutputFile > myFinalFile

check 'myFinalFile' file.
Good luck!
# 5  
Old 01-09-2009
Thanks

It is working fine.

Last edited by ammu; 01-09-2009 at 01:34 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Problem with replacing chars in file

my file is : hello1 hello2 hello3_B,dummy,N Need to change to : hello1 hello2 hello3_B,dummy_01,N Can anyone help? Thank you. Please use code tags next time for your code and data. (6 Replies)
Discussion started by: Alyssa
6 Replies

2. Shell Programming and Scripting

Problem while replacing text between two tags

Hi, I have a file i which i want to replace {gIntegraHost} to {gTestRunHost} between <TCPSampler and curl only. I am firing below command sed '1,/<TCPSampler/!{ /curl/,/<TCPSampler/!s/{gIntegraHost}/{gTestRunHost}/; }' file1 But only on instance is getting replaced not all. Any idea how... (6 Replies)
Discussion started by: abhitanshu
6 Replies

3. Shell Programming and Scripting

problem in replacing asterisk in sed

Hi all, Sed is the one which always trobules me :( here is my input : *** it industry need to be evolved *** in the world and hope so *** to be dream the output i am expecting is : *** it industry need to be evolved *** in the world and hope so *** to be dream ... (4 Replies)
Discussion started by: panyam
4 Replies

4. Shell Programming and Scripting

problem with sed while replacing a string with another

Hi, I have a line something like this sys,systematic,system I want to replace only the word system with HI I used sed for this as below echo sys,systematic,system | sed 's/system/HI/' but I got output as sys,HIatic,system I wanted output as sys,systematic,HI Please tell me... (9 Replies)
Discussion started by: friendyboy
9 Replies

5. Solaris

routing problem after replacing hard drive

Need to replace hard drive on Ultra 10 running Solaris 2.6. Bought new drive about the same size. Partitioned it differently to solve a space problem. After newfs used tar commands to copy most of the files to the new drive. Installboot took care of the boot file. ufsdump copied /dev and... (3 Replies)
Discussion started by: snorkack59
3 Replies

6. Shell Programming and Scripting

replacing a script while running

Hi there, How can I run a script being sure that it runs all the way to the end even if the source file is deleted or replaced while running? Actually, I have a script that runs daily on several servers. It replaces local files by updates from a master server. But I'd like it to replace itself... (3 Replies)
Discussion started by: chebarbudo
3 Replies

7. Shell Programming and Scripting

SED: Replacing $1 with $2 escape problem

Hi all, I have a script which uses sed to replace one string with another. The problem is, the string to be matched, and its replacement are coming in as two command line arguments $1 and $2 $1 and $2 can be absolutely anything, but both should be treated purely as strings. My sed command... (7 Replies)
Discussion started by: mark007
7 Replies

8. UNIX for Dummies Questions & Answers

sed problem replacing long strings

Hi all, I have a script which uses sed to replace one string with another. The problem is, the string to be matched, and its replacement are coming in as two command line arguments $1 and $2 $1 and $2 can be absolutely anything, but both should be treated purely as strings. My sed command... (1 Reply)
Discussion started by: mark007
1 Replies

9. Shell Programming and Scripting

problem in replacing a string

Hi, I have a file with the path of the directory present somewhere in it.I have assigned the path of the directory name to a variable. I want to replace it with another string.The code i used was sed -e '/$variable/sbcd/' filename. since the path name includes slashes '/', my sed command... (9 Replies)
Discussion started by: ragavhere
9 Replies

10. Shell Programming and Scripting

Problem replacing the string

I have three files that the string inside it I want to replace so my code will be #!/bin/bash read -p "please input the old string:" string1 read -p "please input the new string:" string2 sed -i "s/string1/string2/g" *.c but the problem is.. the string that I want to replace can't be... (2 Replies)
Discussion started by: Viken
2 Replies
Login or Register to Ask a Question