LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Find + sed did not replaced IPs, any idea why? (https://www.linuxquestions.org/questions/linux-newbie-8/find-sed-did-not-replaced-ips-any-idea-why-4175497845/)

postcd 03-11-2014 05:15 PM

Find + sed did not replaced IPs, any idea why?
 
Hello, this command:

Code:

find /home/vps/$VMID/etc -type f -print0 | xargs -0 sed -i 's|$OLDIP|$NEWIP|g'
any idea why this command in a bash script did not replaced IPs?

am i needed to comment out the dots in ips? \.

custangro 03-11-2014 05:20 PM

Hard to tell without your script...what does
Quote:

$VMID
$OLDIP
$NEWIP
expand to?

sycamorex 03-11-2014 05:46 PM

Also, for variable substitution use double quotes:

Code:

"s|$OLDIP|$NEWIP|g"

postcd 03-11-2014 06:25 PM

Thanks, i will try this (double quotes) in next script run..

UPDATE: and it worked.. double quotes and ; at the end....

vmid is number
ip is IP

sycamorex 03-11-2014 06:42 PM

Glad it works. For anything 'sed' check this tutorial:
http://www.grymoire.com/Unix/Sed.html

If you think your problem has been solved, you mark this thread as solved in the thread tools.


All times are GMT -5. The time now is 03:04 AM.