![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| replacing string in an XML file | subin_bala | Shell Programming and Scripting | 2 | 06-03-2008 04:14 AM |
| Replacing Last occurance of & from a string | vivekshady | Shell Programming and Scripting | 1 | 05-13-2008 05:15 PM |
| problem in replacing a string | ragavhere | Shell Programming and Scripting | 9 | 05-02-2008 06:02 AM |
| Replacing string in files | mohan705 | Shell Programming and Scripting | 2 | 08-28-2007 10:27 PM |
| string replacing | priya_9patil | Shell Programming and Scripting | 1 | 11-03-2006 09:05 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 changed is that possible the code that i wrote is wrong ? there is have any solution ? thank you |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
string1 and string2 are variables. when you call variables, put $. something like this
eg Code:
sed -i "s/$string1/$string2/g" *.c |
|
#3
|
|||
|
|||
|
Thank you very much
|
|||
| Google The UNIX and Linux Forums |