[svlug] Quick shell question
Tim Pepper
tpepper at vato.org
Tue Jun 27 15:34:18 PDT 2000
On Mon, 26 Jun 2000, Ivan Passos wrote:
>
> On Mon, 26 Jun 2000, Ray Olszewski wrote:
>
> > >I have a file called -C . How do I delete this file??
> > >
> > >As y'all know, 'rm -rf -C' doesn't cut it ... ;)
> >
> > Does "rm -i *C" work?
>
> No, it doesn't:
>
> $ rm -i *C
> rm: invalid option -- C
> Try `rm --help' for more information.
> $
>
> It reads the '-C' argument anyway.
As it should...
The shell does expansion, so "rm -i *C" will get expanded to 'rm -i -C' and rm
will see the -C as an attempt at an argument.
I was soooo stumped by something like this the other day. Had a shell script
invoked as "foo *.foo" and wanted to get "*.foo" inside the script and was
just using $1 in the script. The code only ever ran against one file. After
an embarassingly long time I realised that *.foo was expanded into all the
matching patterns which then came in on $1, $2, ...
t.
--
*********************************************************
* tpepper at vato dot org * Venimus, Vidimus, *
* http://www.vato.org/~tpepper * Dolavimus *
*********************************************************
More information about the svlug
mailing list