Re: [SLUG] Bash script

From: Eben King (eben1@tampabay.rr.com)
Date: Tue May 24 2005 - 08:55:50 EDT


On Tue, 24 May 2005, Paul M Foster wrote:

> On Thu, May 19, 2005 at 11:00:02PM -0400, Bob Stia wrote:
>
> > cd $FROM_DIR
>
> Someone else mentioned $VARNAME versus ${VARNAME}. No, you won't find
> this exact thing in your script, but the above is an example of what the
> poster meant. When he said "VARNAME", he meant "variable name". Anything
> preceded by a $ in a bash script is a variable. In this case, the
> variable name is $FROM_DIR. In bash, you can also say ${FROM_DIR}, and
> it means mostly the same thing. In most cases, it's a matter of
> preference which form you use. In some cases you need to use ${FROM_DIR}
> instead. But I don't think you have any of that kind of thing in your
> script.

The difference between $VARNAME and ${VARNAME} arises when you set VARNAME
to something (for example):

VARNAME=foo

Then

echo $VARNAMEABC

will print nothing (assuming nothing's in a variable called "VARNAMEABC")
while

echo ${VARNAME}ABC

fooABC

Using {} can never hurt (when used properly) and can sometimes help.

> > for i in *.$FROM; do
> >
> >   echo $1
>
> The above appears to by line 35 by my count. Terms like $0, $1, $2
> indicate the parameters with which you call the program. $0 is always
> the name of the script. So for example, if you said:
>
> bobs_script joe sam
>
> then those variables would be as follows:
>
> $0 = bobs_script
> $1 = joe
> $2 = sam
>
> You can see from this how it would progress; the next thing on the
> command line corresponds to the next number.
>
> In this case, I don't think you're actually passing the script any
> parameters, so the $1 is meaningless. I suspect this should be
>
> echo $i
>
> instead of echo $1. That way the script would tell you what file it was
> processing for each loop.

What he said.

> If my count is right, I don't know why your script is telling you this
> line is an unknown command. I suspect there is some alteration between
> the running script and what you posted. Otherwise, it doesn't make
> sense.

Is this /home/bob/commands/ImageMagickConvert ?

-- 
-eben    ebQenW1@EtaRmpTabYayU.rIr.OcoPm    home.tampabay.rr.com/hactar
CAPRICORN:  The stars say you're an exciting and wonderful person...
but you know they're lying.  If I were you, I'd lock my doors and
windows and never never never never leave my house again.  -- Weird Al

----------------------------------------------------------------------- This list is provided as an unmoderated internet service by Networked Knowledge Systems (NKS). Views and opinions expressed in messages posted are those of the author and do not necessarily reflect the official policy or position of NKS or any of its employees.



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 19:08:05 EDT