FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > CentOS > CentOS

 
 
LinkBack Thread Tools
 
Old 06-19-2012, 05:30 AM
 
Default replace string with sed but not the first one

Hi,
*
We have a the following file
[ip-map]
# Unchanged IP addresses:
# Please review default IP addresses mapping below:
192.168.1.10*shared*** ->***** 192.168.123.6 shared
[namexx]
192.168.1.10
naam** 192.168.1.10



We want to replace 192.168.1.10* to a other string but i don't want to change te first one.
*
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 06-19-2012, 05:36 AM
Mark Pryor
 
Default replace string with sed but not the first one

----- Original Message -----
From: "maverh@telenet.be" <maverh@telenet.be>
To: centos@centos.org
Cc:
Sent: Monday, June 18, 2012 10:30 PM
Subject: [CentOS] replace string with sed but not the first one




Hi,
*
We have a the following file
[ip-map]
# Unchanged IP addresses:
# Please review default IP addresses mapping below:
192.168.1.10*shared*** ->***** 192.168.123.6 shared
[namexx]
192.168.1.10
naam** 192.168.1.10



We want to replace 192.168.1.10* to a other string but i don't want to change te first one.
-----------
cat >> cml.txt<<EOL
[ip-map]
# Unchanged IP addresses:
# Please review default IP addresses mapping below:
192.168.1.10*shared*** ->***** 192.168.123.6 shared
[namexx]
192.168.1.10
naam** 192.168.1.10
EOL

sed -i -e 's/192.168.1.10$/192.168.1.11/g' cml.txt

--
Mark

_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 06-19-2012, 07:18 AM
 
Default replace string with sed but not the first one

Thanks


----- Oorspronkelijk e-mail -----
Van: "Mark Pryor" <tlviewer@yahoo.com>
Aan: "CentOS mailing list" <centos@centos.org>
Verzonden: Dinsdag 19 juni 2012 07:36:54
Onderwerp: Re: [CentOS] replace string with sed but not the first one





----- Original Message -----
From: "maverh@telenet.be" <maverh@telenet.be>
To: centos@centos.org
Cc:
Sent: Monday, June 18, 2012 10:30 PM
Subject: [CentOS] replace string with sed but not the first one




Hi,
*
We have a the following file
[ip-map]
# Unchanged IP addresses:
# Please review default IP addresses mapping below:
192.168.1.10*shared*** ->***** 192.168.123.6 shared
[namexx]
192.168.1.10
naam** 192.168.1.10



We want to replace 192.168.1.10* to a other string but i don't want to change te first one.
-----------
cat >> cml.txt<<EOL
[ip-map]
# Unchanged IP addresses:
# Please review default IP addresses mapping below:
192.168.1.10*shared*** ->***** 192.168.123.6 shared
[namexx]
192.168.1.10
naam** 192.168.1.10
EOL

sed -i -e 's/192.168.1.10$/192.168.1.11/g' cml.txt

--
Mark

_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 

Thread Tools




All times are GMT. The time now is 04:41 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org