1753876 Members
7596 Online
108809 Solutions
New Discussion юеВ

sed question

 
SOLVED
Go to solution
Ralf Buchhold
Regular Advisor

sed question

Hello

I want to substitute "**OUT_FILE**" with
"/usr/home/name/file.dat" (= $NAME)

But it dont works with:

sed "s/**OUT_FILE**/$NAME/g" inp > out
Any idea
Ralf
6 REPLIES 6
Alex Lavrov.
Honored Contributor

Re: sed question

I think you should escape "*" with "\".
Somethink like this:

sed "s/\*\*OUT_FILE\*\*/$NAME/g" inp > out

I don't give a damn for a man that can only spell a word one way. (M. Twain)
Ralf Buchhold
Regular Advisor

Re: sed question

Hello Alex
I think the problem are the / in the $NAME
Ralf
Steven E. Protter
Exalted Contributor

Re: sed question

Sometimes it helps to do this:

change $NAME

to

${NAME}

This makes it clear to the shell where the variable ends.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Ralf Buchhold
Regular Advisor

Re: sed question

Hello
no sorry but it doesnt work
Do you have other posibilities ?

perhaps with awk ?

Thanks Ralf
Sergejs Svitnevs
Honored Contributor
Solution

Re: sed question

NAME="\/usr\/home\/name\/file\.dat"
sed "s/\*\*OUT_FILE\*\*/$NAME/g" inp > out

work fine for me

Regards,
Sergejs
Ralf Buchhold
Regular Advisor

Re: sed question

Thanks Ser...

I works fine