Mostly Linux & Python syntax notes and hyperlinks.

Friday, August 14, 2009

tar with exclude, rm files starting with -

To tar up a directory without the subversion folders embedded throughout:

$ tar cvf file.tar directorytotar --exclude .svn

or

$ cat > exclude
.svn
[control-D]

$ tar cvjf file.tar directorytotar -X exclude

If you goofed and tried it this way first:
tar cvjf -X .svn file.tar directorytotar
tar --exclude .svn cvf file.tar directorytotar

You're then stuck with a file named --exclude or -X

You can't do

$ rm -X
rm: invalid option -- X
Try `rm --help' for more information.


Instead, do rm ./-X or rm -- -X

$ rm ./-X
rm: remove regular empty file `./-X'? y
removed `./-X'

from http://www.cyberciti.biz/faq/unix-linux-remove-strange-names-files/

No comments:

Post a Comment