Article View: comp.unix.shell
Article #1762Re: command substitution
From: Tom Christiansen
Date: Thu, 08 Nov 1990 04:11
Date: Thu, 08 Nov 1990 04:11
35 lines
1424 bytes
1424 bytes
In article <5697@alpha.cam.nist.gov> coleman@cam.nist.gov (Sean Sheridan Coleman X5672) writes:
>I really want to do the following:
>
>set date = `basename `awk '{print $7}' /tmp/process.$$``
I'm sure I just saw something like this. If you were using ksh, you could
simply say:
date=$(basename $(awk '{print $7}' /tmp/process.$$))
and be done with it, but for the csh, you're going to have to go through
more convolutions to achieve the same effect.
You have to do it in two manual stages;
set widget = `awk '{print $7}' /tmp/process.$$`
set date = `basename $widget`
should work. I found that quoting the widget string was enough,
so I think this will work for you:
set widget = '`awk '"'"'{print $7}'"'"' /tmp/process.$$`'
set date = `basename $widget`
because this worked for me:
set cmd = '`whoami`'
echo i am `id $cmd`
which came as a bit of a surprise. You can do the same thing in /bin/sh, too:
cmd='`whoami`'
echo i am `id $cmd`
--tom
Technical Details
Message-ID:
<108388@convex.convex.com>Path:
arc1-ca.pugleaf.net!utzoo!attcan!uunet!convex!convex.COMReferences:
<5697@alpha.cam.nist.gov>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!convex!convex.COM From: tchrist@convex.COM (Tom Christiansen) Newsgroups: comp.unix.shell Subject: Re: command substitution Message-ID: <108388@convex.convex.com> Date: 8 Nov 90 04:11:54 GMT References: <5697@alpha.cam.nist.gov> Sender: usenet@convex.com Reply-To: tchrist@convex.COM (Tom Christiansen) Organization: CONVEX Software Development, Richardson, TX Lines: 35