Removing a file whose name starts with '-', was Re: How to command line rotate an image?
Mike Ballon
mike.ballon at gmail.com
Fri Nov 12 08:26:26 MST 2010
OK, this is the last time I answer from the bar :)
I didn't mean that using inodes was the "only" way, I just knew it would
work.
I also stated that the syntax might not be correct as I didn't test it.
[name at hostd1 ~]$ ls -li
total 64
31758 -rw-rw-r-- 1 user group 4549 Oct 21 14:50 text.html
[name at hostd1 ~]$ find . -inum 31758 -exec rm -i {} \;
rm: remove regular file `./text.html'? y
You could also use find . -inum 31758 | xargs rm
I think CLI users should be aware of multiple options so thanks to those
that replied with how to escape the special characters.
-Mike
On Fri, Nov 12, 2010 at 9:42 AM, Dale Farnsworth <dale at farnsworth.org>wrote:
> > 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
>
> ---------------------------------------------------
> PLUG-discuss mailing list - PLUG-discuss at lists.plug.phoenix.az.us
> To subscribe, unsubscribe, or to change your mail settings:
> http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.PLUG.phoenix.az.us/pipermail/plug-discuss/attachments/20101112/bd378eca/attachment.html>
More information about the PLUG-discuss
mailing list