RE: Bash Script Questions

2001-01-26 Thread Brad Doster
>> Look at manipulating the IFS variable; you can do wondrous things with that. Yep, I've thought about it, but that's all so far. >> Next, we get into opening and using file descriptors... All in good time. :) bd ___ Redhat-list mailing list [EMA

RE: Bash Script Questions

2001-01-26 Thread Brad Doster
>> See my other replies for more thoughts on this, but it actually has to be >> "s/$//g", and must use "s rather than 's. Whoops! My bad. :) Both of these work... 's/\\$//g' # single quotes "s/$//g"# double quotes Thanks to Matthew for catching my goof

RE: Bash Script Questions

2001-01-26 Thread Brad Doster
>> That's making the big assumption that wrong sort of quotes is your problem. >> If not then umm.. err.. *shurg* ... Did i meantion in worked for me? ;) Yep, you nailed it. Thanks for taking time to post the echo examples! bd ___ Redhat-list maili

Re: Bash Script Questions

2001-01-26 Thread Dave Ihnat
On Fri, Jan 26, 2001 at 09:41:30AM -0800, Brad Doster wrote: > IOW, I can treat the list as space or line delimited. Using var3=`echo > "$var1\n$var2"` eliminates the ability to treat it as a space delimilted > list as 'echo $var3' and 'echo "$var3"' both produce 'a\nb'. Well, in one sense--in a

RE: Bash Script Questions

2001-01-26 Thread Brad Doster
>> Now what you should do is store the \n's in var3 like: >> var3=`echo "$var1\n$var2"` >> after which: >> echo -e $var3 >> would give the desired output Yep, that works too. But :), var3=`echo -e "$var1\n$var2"` seems to be a bit more flexible in that 'echo $var3' produces... a b ...a

RE: Bash Script Questions

2001-01-26 Thread Brad Doster
>> varlist=`echo "$varlist" | sed 's/\\$//'` See my other replies for more thoughts on this, but it actually has to be "s/$//g", and must use "s rather than 's. Thanks for your input! bd ___ Redhat-list mailing list [EMAIL PROTECTED] https://li

RE: Bash Script Questions

2001-01-26 Thread Brad Doster
= Brad Doster Insight Network Solutions www.InsightNetSolutions.net 925.335.9510 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Luke C Gavel Sent: Friday, January 26, 2001 2:18 AM To: [EMAIL PROTECTED] Subject: RE: Bash Script Questions

RE: Bash Script Questions

2001-01-26 Thread Matthew Melvin
On Fri, 26 Jan 2001 at 8:34am (-0800), Brad Doster wrote: > >> 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 '\$

RE: Bash Script Questions

2001-01-26 Thread Brad Doster
-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 do

RE: Bash Script Questions

2001-01-26 Thread Stephen_Reilly
>> var3=`echo -e "$var1\n$var2"` >>...does the trick. It's the -e option in echo that's doing this, it allows the \n to be read and used as a new line. e.g. echo -e "$var1\n$var2" should read: a b but echo var3 after above would still give: a b Now what you should do is store the \n's in v

RE: Bash Script Questions

2001-01-26 Thread Stephen_Reilly
probably a bit late with this but; > > varlist=`echo "$varlist" | sed 's/$//'` > varlist=`echo "$varlist" | sed 's/\\$//'` > > 2) Given two variables, say var1="a" and var2="b", I want to create var3 > > such that it is "ab", i.e 'echo "$var3"' produces: > > > > a > > b > > > You w

RE: Bash Script Questions

2001-01-26 Thread Luke C Gavel
On Thu, 25 Jan 2001, Brad Doster wrote: > But why? Why doesn't good ol' '\$' work right out of the > box? Because the '$' is used in a special by the shell (script) and sed too. sed uses the '$' to anchor a search pattern from the end of a line, and, of course the script uses it to expand vari

RE: Bash Script Questions

2001-01-25 Thread Matthew Melvin
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

RE: Bash Script Questions

2001-01-25 Thread Brad Doster
>> varlist=`echo "$varlist" | sed -e "s/$//g" Yep, that did it! But, what did it do? Or, where can I find info that will help me make sense of it? FWIW, it looks to me like it's searching for '\\$' (???). Oooh it is! But the '\\$' gets reduced to '\$' which then works as desired.

RE: Bash Script Questions

2001-01-25 Thread Brad Doster
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 " | se

Re: Bash Script Questions

2001-01-25 Thread Matthew Melvin
On Thu, 25 Jan 2001 at 10:21am (-0800), Brad Doster wrote: > 1) I have a variable with a list of variable names as its content, e.g. > 'varlist=$var1 $var2 $var3'. I want to manipulate $varlist such that it > ='var1 var2 var3', i.e get rid of the '$'s in front of each variable name. > A 'sed' ex

Re: Bash Script Questions

2001-01-25 Thread Dave Ihnat
On Thu, Jan 25, 2001 at 10:21:39AM -0800, Brad Doster wrote: > 1) I have a variable with a list of variable names as its content, e.g. > 'varlist=$var1 $var2 $var3'. I want to manipulate $varlist such that it > ='var1 var2 var3', i.e get rid of the '$'s in front of each variable name. > A 'sed' e