Removing a file whose name starts with '-', was Re: How to command line rotate an image?

Dale Farnsworth dale at farnsworth.org
Fri Nov 12 07:42:12 MST 2010


> I don't know who to rotate the image, but to delete your file you need
> to use the inode. This is off the top of my head so if the synax is
> wrong you can just google it.
> 
> ls -il "-rotate90"
> 
> find . -inum 123456 -exec rm -i {} \;

The above suggestion doesn't work because the ls command fails.  It's
also a very roundabout way to delete a file.  There is no need to use
i-numbers.

The manual page for rm says:
	To  remove a file whose name starts with a ‘-’, for example ‘-foo’,
	use one of these commands:

		rm -- -foo

		rm ./-foo

Using "--" to separate flags/options from filenames works for many
commands, including ls.

-Dale


More information about the PLUG-discuss mailing list