03-16-06 01:48 AM
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
[ Post a follow-up to this message ]
|