[vox-tech] bash question
Ken Bloom
vox-tech@lists.lugod.org
Thu, 9 Jan 2003 07:52:39 -0800
> ---ORIGINAL MESSAGE---
> Date: Wed, 08 Jan 2003 12:13:54 -0800
> From: Matt Holland <mdholland@ucdavis.edu>
> To: vox-tech@lists.lugod.org
> Subject: Re: [vox-tech] bash question
> Reply-To: vox-tech@lists.lugod.org
>
> Sorry, the example isn't quite clear... the only reason for the line
> containing only '"$1";' was to demonstrate that the program that's
> getting called by the script is in the path, and that the program runs.
> The line before that is also quite stripped down from what I would use
> in the case I'm actually interested in:
>
> "$1 -i$I -$2 -$3 -$4 -o$3/$J.out > /dev/null";
>
> But it contained the elements that I wanted to test. Anyway, thanks,
> because the problem seems to have been the quotes. I thought I needed
> the quotes to force substitution of $1, $2, etc., but it seems I was wrong.
>
The shells have three kinds of quotes. Double quotes " " will supress
filename substitution for the * and ? characters, and whatever is
between the quotes (including spaces) will be treated as a single token.
Single quotes (apostrophes) ' ' will supress filename substitutions and
variable substitutions and command substitutions (but for some reason in
tcsh it doesn't supress history substitutions), and whatever is between
the quotes (including spaces) will be treated as a single token.
Backquotes ` ` are equivalent in bash to $( ), and anything between them
is regarded as a command to be run, and whatever that command writes to
standard output is substituted (as multiple tokens, unless the whole
construct is listed in quotes).
Try the following to give you a good example of what goes on:
mkdir test
cd test
ls
touch *
ls
touch "*"
ls
thouch "$USER"
ls
touch '$USER'
ls
touch `date`
ls
touch "`date`"
ls
touch '`date`'
ls
when you're done, use rm -i * to delete everything