LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-11-2014, 06:15 PM   #1
postcd
Member
 
Registered: Oct 2013
Posts: 443

Rep: Reputation: Disabled
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? \.
 
Old 03-11-2014, 06:20 PM   #2
custangro
Senior Member
 
Registered: Nov 2006
Location: California
Distribution: Fedora , CentOS , RHEL
Posts: 1,977
Blog Entries: 1

Rep: Reputation: 209Reputation: 209Reputation: 209
Hard to tell without your script...what does
Quote:
$VMID
$OLDIP
$NEWIP
expand to?
 
Old 03-11-2014, 06:46 PM   #3
sycamorex
LQ Veteran
 
Registered: Nov 2005
Location: London
Distribution: Slackware64-current
Posts: 5,825
Blog Entries: 1

Rep: Reputation: 1221Reputation: 1221Reputation: 1221Reputation: 1221Reputation: 1221Reputation: 1221Reputation: 1221Reputation: 1221Reputation: 1221
Also, for variable substitution use double quotes:

Code:
"s|$OLDIP|$NEWIP|g"
 
1 members found this post helpful.
Old 03-11-2014, 07:25 PM   #4
postcd
Member
 
Registered: Oct 2013
Posts: 443

Original Poster
Rep: Reputation: Disabled
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
 
Old 03-11-2014, 07:42 PM   #5
sycamorex
LQ Veteran
 
Registered: Nov 2005
Location: London
Distribution: Slackware64-current
Posts: 5,825
Blog Entries: 1

Rep: Reputation: 1221Reputation: 1221Reputation: 1221Reputation: 1221Reputation: 1221Reputation: 1221Reputation: 1221Reputation: 1221Reputation: 1221
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Find URL in Debian package index via awk/sed (=find a line, then search from there) maddes.b Linux - Software 11 06-28-2013 08:37 AM
How can I grep/sed the ips only from /var/log/messages? abefroman Programming 1 07-31-2009 02:47 PM
replaced variable field within shell script using sed hamimi Linux - Newbie 2 05-28-2008 09:01 AM
How can I awk/sed/grep the IPs from the maillog? abefroman Programming 7 03-09-2006 11:22 AM
how squid find ips mchitrakar Linux - Networking 3 06-11-2004 08:50 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:05 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration