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


 
 
LinkBack Thread Tools
 
Old 10-24-2010, 06:18 PM
Raj Har
 
Default append

hello all,
i am trying to append some thing in some file.

cat r1;
out put 172.24.0.1

sed '10s/$/172.24.0.254/' file.txt i want replace 172.24.0.254 ip
address by r1 out put.

can we make r1 out put as sed command input??
--
redhat-list mailing list
unsubscribe mailto:redhat-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list
 
Old 10-24-2010, 10:47 PM
Cameron Simpson
 
Default append

On 24Oct2010 23:48, Raj Har <raj4list@gmail.com> wrote:
| hello all,
| i am trying to append some thing in some file.
|
| cat r1;
| out put 172.24.0.1
|
| sed '10s/$/172.24.0.254/' file.txt i want replace 172.24.0.254 ip
| address by r1 out put.
|
| can we make r1 out put as sed command input??

Sure. Like this (untested):

r1text=`cat r1` # backticks, not single quotes
sed "10s/$/$r1text/" file.txt

Note double quotes (") instead of single quotes ('); that lets parameter
substitution ($r1text) take place in the sed argument. Then, because $
now starts a parameter, you need to escape the $ you are using for "end
of line", so it becomes "$" instead of "$". The result is that sed's
first argument becomes:

10s/$/172.24.0.1/

as you intended.

Cheers,
--
Cameron Simpson <cs@zip.com.au> DoD#743
http://www.cskk.ezoshosting.com/cs/

"If you could have any amount of money... How much would you want?"
"All of it." - Cerebus the Aardvark

--
redhat-list mailing list
unsubscribe mailto:redhat-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list
 

Thread Tools




All times are GMT. The time now is 05:49 AM.

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