On Thu, 25 Jan 2001 at 7:56pm (-0800), Brad Doster wrote:
> Hi Matthew,
>
> Perhaps what I'm doing in the '$' case needs a bit more explanation. The
> following is a script segment that gleans variable names from the script in
> which it is run:
>
> for varname in case select until while ; do
> varlist=`cat "$0" | grep "^[ ]*$varname " | sed 's/ \[
> //' \
> | awk '{print $2}' | awk -F "$" '{print $2}' | sed 's/"//g'`
> done
>
> This bit works as it's using the 'awk -F' alternative to the sed chunk I
> posted in my first message. I think the problem when using sed is related
> to parameter expansion, since the variable names are live in the script.
> IOW, when using sed, maybe it's working on the values of the variables
> rather than the names of them?
>
> I've tried pulling the sed (or 'awk -F') out of the above line, then using a
> second line like...
>
> varlist=`echo "$varlist" | sed 's/\$//g'`
>
> ...but the resulting varlist still has the '$'s in it when done.
Ahhh.. we need another \ - one to protect $ from sed and another to protect
the first \ from the backticks.
varlist=`echo "$varlist" | sed 's/\\$//g'`
> As you can see, I have an alternative, so this isn't critical, but I sure am
> curious! Maybe I'm just a fool for trying to throw away $ <g>.
>
> As for the <newline> problem, I found that the following works:
>
> var=`echo -e "a\nb"`
> echo "$var"
>
Duh. of course - quote the echo. :)
M.
--
WebCentral Pty Ltd Australia's #1 Internet Web Hosting Company
Level 1, 96 Lytton Road. Network Operations - Systems Engineer
PO Box 4169, East Brisbane. phone: +61 7 3249 2583
Queensland, Australia. pgp key id: 0x900E515F
_______________________________________________
Redhat-list mailing list
[EMAIL PROTECTED]
https://listman.redhat.com/mailman/listinfo/redhat-list