sed question

sed question

Post by Joey Montill » Fri, 07 Apr 2000 04:00:00



Hi,

I am trying to insert an executable string inside a sed command in the
hopes that it will work.

ie:

cat filename | sed -e 's/system/`uname -n`/g'

I want uname -n to execute but to no avail.
How do I do this ?
Or is there a better way ?

Thanks

 
 
 

sed question

Post by Noel Nihil » Fri, 07 Apr 2000 04:00:00


Hi...

set sys=`uname -n `
unset noclobber
cat filename | sed 's/system/ ' "$sys " '/g' > filename

...should do the trick. You could stick it in a script.

Noel.


Quote:> Hi,

> I am trying to insert an executable string inside a sed command in the
> hopes that it will work.

> ie:

> cat filename | sed -e 's/system/`uname -n`/g'

> I want uname -n to execute but to no avail.
> How do I do this ?
> Or is there a better way ?

> Thanks


 
 
 

sed question

Post by Noel Nihil » Fri, 07 Apr 2000 04:00:00


Uh oh, don't redirect sed's output to the same file being cat-ed, or
it'll get clobbered. I shot myself in the foot like that before!!

N.


Quote:> Hi,

> I am trying to insert an executable string inside a sed command in the
> hopes that it will work.

> ie:

> cat filename | sed -e 's/system/`uname -n`/g'

> I want uname -n to execute but to no avail.
> How do I do this ?
> Or is there a better way ?

> Thanks

 
 
 

sed question

Post by Mark Bradle » Fri, 07 Apr 2000 04:00:00


Try double quotes

ie

cat filename | sed -e "s/system/`uname -n`/g"


> I am trying to insert an executable string inside a sed command in the
> hopes that it will work.

> ie:

> cat filename | sed -e 's/system/`uname -n`/g'

 
 
 

sed question

Post by Keith Thompso » Sat, 08 Apr 2000 04:00:00




> > I am trying to insert an executable string inside a sed command in the
> > hopes that it will work.

> > ie:

> > cat filename | sed -e 's/system/`uname -n`/g'
[...]
> Try double quotes

> ie

> cat filename | sed -e "s/system/`uname -n`/g"

Note that the "cat filename |" is wasteful; use this instead:

sed -e "s/system/`uname -n`/g" filename

--

San Diego Supercomputer Center           <*>  <http://www.sdsc.edu/~kst>
Welcome to the last year of the 20th century.

 
 
 

1. yet another sed question ...

Hi all, I need to extract the latest RCS version numbers directly from
a bunch of RCS files.  The first lines of those files are all in the
form of "head 1.20;" where 1.20 (or some other number) is the number I
want to extract.

I tried the following command in my sh script:

  head -1 filename | sed -n 's/^head *\([0-9]*\.[0-9]*\)/\1/p'
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

but nothing came out.  The result from "head -1 filename" in this case
is "head    1.20;".  Couldn't figure out while, I tried at command
line the following:

  echo "head    1.20;" | sed -n 's/^head *\([0-9]*\.[0-9]*\)/\1/p'
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

and got the correct result "1.20".  BTW, I tried the first form on
command line too.

Can some enlighten me while the world the first form didn't work?

I'm currently using :

  head -1 filename |awk '{print $2}' |awk -F";" ' {print $1}'

it works but obviously not efficient.

Thanks for any help!

Rose Sun

2. CDROM gives SCSI errors

3. newbie sed question

4. To click, to not to click

5. sed question

6. spurious 8259A interrupt: IRQ7

7. One more sed question...

8. RPC service trouble

9. another sed question

10. SED Questions

11. sed question

12. Sed question for newbie

13. Sed Question