Re: Get the parameter pattern from command line
am 30.03.2008 18:59:41 von PKAlvin SIU wrote:
> When I issue the following :
> viewfile.ksh a*
Well, probably a dirty trick (whose applicability in your case I don't
know), however it should not be too difficult to call it using 'a*' (with
single quotes) and do the expansion inside, eg
$ cat filter.sh
#!/bin/sh
filter=$1 # save filter
set -- $1 # set positional parameters
printf "Filter is %s\n" "$filter"
n=1
for i in "$@"; do
printf "Argument %d is %s\n" "$n" "$i"
n=$((n+1))
done
$ ls a*
a b c d.txt a.sh a.txt
$ ./filter.sh 'a*'
Filter: a*
Argument 1 is a b c d.txt
Argument 2 is a.sh
Argument 3 is a.txt
--
All the commands are tested with bash and GNU tools, so they may use
nonstandard features. I try to mention when something is nonstandard (if
I'm aware of that), but I may miss something. Corrections are welcome.