command substitution using sed

command substitution using sed

Post by mla.. » Tue, 29 Jun 1999 04:00:00



Does anyone know if we can use command substitution in sed?
For example, I want to replace a line of text in a file


where date is the output of the date command.

Thanks,

John

Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.

 
 
 

command substitution using sed

Post by Charles Dem » Tue, 29 Jun 1999 04:00:00




>Does anyone know if we can use command substitution in sed?
>For example, I want to replace a line of text in a file


>where date is the output of the date command.

This is a shell quoting problem

here are several solutions that will work:




BTW, the following does not work as you probably found out:


That's because of what doesn't happen inside single quotes.

read the man page for your shell and concentrate on the quoting
aspects.

man sh

Chuck Demas
Needham, Mass.

--
  Eat Healthy    |   _ _   | Nothing would be done at all,

  Die Anyway     |    v    | That no one could find fault with it.


 
 
 

command substitution using sed

Post by Dav » Wed, 30 Jun 1999 04:00:00


Your best bet:
DATE=`date`

#note the quotes around the sed argument...they allow the shell to
expand the $DATE variable.

cheers,
Dave


> Does anyone know if we can use command substitution in sed?
> For example, I want to replace a line of text in a file


> where date is the output of the date command.

> Thanks,

> John

> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.

+---------------------+---------------+


+---------------------+---------------+