[Techtalk] Really dumb filename question...

Mandi mandi at linuxchick.org
Tue Aug 26 11:00:21 EST 2003


> I was trying to package up some files this morning and typed something
> similar to this:
> 
> tar czf --exclude=`*.php' --exclude='*.html' sourcedir
> 
> If you're more awake than I was, you'll realized that I probably forgot to
> put a file name in there.  You probably also realized that I now have an
> archive named '--exclude=*.exe'.  Ooops!
> 
> Ok, so that was a simple enough mistake that should be easily corrected,
> right?  I can't seem to figure out the magic escape sequence to get any
> thing to treat it as a filename instead of a commandline parameter.
> 
> My first thought was wildcards, but it doesn't like that at all.
> 
> rm *.pdf <failed>
> rm \-* <failed>
> 
> The same goes for any other combination I could think of.  I even tried
> rm -rf sourcedir!

magical double hyphen

rm -rf -- --exclude=*.3

>From the rm manpage:
	GNU rm, like every program that uses the  getopt  function
       	to  parse  its  arguments,  lets  you use the -- option to
       	indicate that all following arguments are non-options.  To
       	remove  a  file  called `-f' in the current directory, you
       	could type either
              rm -- -f
       	or
              rm ./-f

Other unixy rm's use the mystical single hyphen that predates the 
enlightenment of getopt.

HTH

--mandi


More information about the Techtalk mailing list