|
Home > Archive > Unix Shell > March 2006 > why $* ?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
|
| Can someone please tell me why is the $* there in the following
example:
awk -F, '{
print $4 ", " $0
}' $*
| |
| Janis Papanagnou 2006-03-15, 8:48 pm |
| yusuf wrote:
> Can someone please tell me why is the $* there in the following
> example:
>
> awk -F, '{
> print $4 ", " $0
> }' $*
>
The $* expands on shell level to a list of words that has been
passed to the script containing these lines.
Say, these lines are in a script called 'mysript' and the script
is called this way...
myscript a b "c d" e
then within the shell program myscript it expands to...
awk -F, '{
print $4 ", " $0
}' a b c d e
The arguments a, b, c, d, e are then taken as the input data files
for the awk program.
The input files contain likely comma separated values (the "-F,").
Mind a couple things...
$4 and $0 are variables within awk
$* is a predefined shell variable
$* will split arguments that contain spaces (like "c d"); use the
quoted "$@" variable if you want it expanded as it has been passed
Janis
| |
| Bill Marcum 2006-03-16, 5:53 pm |
| On 15 Mar 2006 16:52:36 -0800, yusuf
<yusufm@gmail.com> wrote:
> Can someone please tell me why is the $* there in the following
> example:
>
> awk -F, '{
> print $4 ", " $0
> }' $*
>
Because the script writer didn't know to use "$@".
--
leverage, n.:
Even if someone doesn't care what the world thinks
about them, they always hope their mother doesn't find out.
|
|
|
|
|