[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: rm and files beginning with a dash
From: |
Bob Proulx |
Subject: |
Re: rm and files beginning with a dash |
Date: |
Sat, 24 Apr 2004 11:48:11 -0600 |
User-agent: |
Mutt/1.3.28i |
Chuck Simmons wrote:
> I could not remove a file whose name began with a dash (e.g.
> "-main-file.tmp"). (Hmmm I suppose I could have tried "rm
> ./-main-file.tmp".) [Actually, I removed the file, but I used a Solaris
> tool to do the job instead of a GNU tool because the Solaris tool seemed
> easier to use.]
You are correct that you could have (should have?) used ./ to avoid
using - as the first character.
> Solaris allows "rm - -main-file.tmp".
You almost had a good general purpose answer. You should use --
instead.
rm -- -main-file.tmp
This is an FAQ.
http://www.gnu.org/software/coreutils/faq/
Look for "How do I remove files that start with a '-'".
> ade:[csimmons_main] dlsun620 csimmons 231> rm --help
> Usage: rm [OPTION]... FILE...
> Remove (unlink) the FILE(s).
>
> -d, --directory unlink directory, even if non-empty (super-user
> only)
> -f, --force ignore nonexistent files, never prompt
> -i, --interactive prompt before any removal
> -r, -R, --recursive remove the contents of directories recursively
> -v, --verbose explain what is being done
> --help display this help and exit
> --version output version information and exit
>
> Report bugs to <address@hidden>.
Thanks for the report. Newer versions also say this in their help
output.
To remove a file whose name starts with a `-', for example `-foo',
use one of these commands:
rm -- -foo
rm ./-foo
Please consider updating to a newer version of coreutils.
ftp://ftp.gnu.org/gnu/coreutils/coreutils-5.2.1.tar.gz
ftp://ftp.gnu.org/gnu/coreutils/coreutils-5.2.1.tar.bz2
(coreutils is the union of fileutils, textutils, and sh-utils)
Bob