>> Ahhh.. we need another \ - one to protect $ from sed and
>> another to protect the first \ from the backticks.
>> varlist=`echo "$varlist" | sed 's/\\$//g'`
Apparently that's still not enough. I think '\\$' parses to '\$' in which
looks like it should be used to look for a literal '$', but apparently
not -- maybe it's looking for '\<endofline>'?
Dave's solution of 's/\\\\$//g' does work. I think '\\\\$' is parsing to
'\\$' and then that to '\$' -- it looks the same, but definitely acts
differently. Maybe we need extra protection for both the '\' and the '$'?
And I thought this was going to be an easy question! :)
bd
===========================
Brad Doster
Insight Network Solutions
www.InsightNetSolutions.net
925.335.9510
-----Original Message-----
From: Matthew Melvin [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 25, 2001 9:57 PM
To: Brad Doster
Cc: [EMAIL PROTECTED]
Subject: RE: Bash Script Questions
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