Home
| Calendar
| Mail Lists
| List Archives
| Desktop SIG
| Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings Linux Cafe | Meeting Notes | Blog | Linux Links | Bling | About BLU |
Matt Brodeur wrote: >> David Rosenstrauch wrote: >>> Matt Brodeur wrote: >>>> Just because you don't have *enough* different answers yet: >>>> >>>> set -- *.zip >>>> if [ -f "${1}" ] ; then >>> Por favor - could you explain this one? > I can't take credit for it. The problem I had was when I changed an > existing script from "check for a file of this name and do something > with it" to "check for files of this pattern and loop through them." > Just using "[ -f filename*" seems to work, as long as there's only one > matching file. With multiple matches you'll get an error from [. > > Googling the right terms reminded me that I'd learned this trick about > eight years ago. Quoth Kochan and Wood[1]: > "The shell's set command is a dual-purpose command: it's used both > to set various shell options as well as reassign the positional > parameters $1, $2, ..." > "...you can use the -- option to set. This tells set not to > interperet any subsequent arguments on the command line as options." > > Note that using set in this fashion resets the parameter list. Make > sure you've already dealt with anything from the command line.
BLU is a member of BostonUserGroups | |
We also thank MIT for the use of their facilities. |