![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Globbing slash Wildcarding Question | scotbuff | Shell Programming and Scripting | 4 | 02-02-2007 12:10 AM |
| Sun: High kernel usage & very high load averages | lorrainenineill | UNIX for Advanced & Expert Users | 4 | 02-06-2006 12:32 PM |
| Preventing wildcard expansion in "read" | gaijin 06 | UNIX for Dummies Questions & Answers | 8 | 11-01-2005 09:31 PM |
| awk / bash globbing question | franzke | Shell Programming and Scripting | 3 | 07-14-2005 11:55 PM |
| Find wildcard .shtml files in wildcard directories and removing them- How's it done? | Neko | UNIX for Dummies Questions & Answers | 1 | 06-27-2001 09:06 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
globbing, $# is too high after wildcard expansion in bash script
How can I pass in an argument such as "*.k" to a bash script
without having to double-quote *.k and not having *.k `glob` to match all files in the pattern? I tried using noglob in my script but this didn't work the way I thought it would.. expansion is still occuring, $# is higher than I expect. Code:
set +o noglob the other positional parameters that I'm passing in. Code:
# Test argument count
USAGE="USAGE: $0 <vertical> <src module> <files(s)> "
#
echo $# $0 $1 $2 $3
if [ $# -ne 3 ]
then
if [ $# -ne 1 -a $1 != "bdat" -a $1 != "cdat" -a $1 != "fdat" -a $1 != "blay" ]
then
echo $# $0 $1 $2 $3
echo $USAGE ; exit 1
fi
fi
TIA Zoo591 |
|
||||
|
We had this discussion in a similar thread recently I think. There's no way you can avoid the globbing occurring within your script because it is performed by the calling shell. If you can live with turning off globbing in your normal shell (which I suspect is unlikely) then you can turn it off there before running your script.
A suggestion here was to use an alias to turn off globbing, however there is no easy way to turn it back on automagically: UNIX Scripting - Turn off file expansion for command line arguments |
|
||||
|
In shell programming / aliasing / set -f this was fixed by combining an alias and a shell function.
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|