[PLUG] Deleting strange file name...

Robert Citek robert.citek at gmail.com
Thu Apr 24 13:41:57 UTC 2008


On Thu, Apr 24, 2008 at 1:21 AM, someone <plug_1 at robinson-west.com> wrote:
> I accidentally trying to tar one file created a file --one-file-system.
>
>  How do I delete without having rm think I'm specifying an option???

Another trick that I've used is to let the shell tell me the file name
by expanding all the files onto the command line and then editing the
command for the files I want.  For example, let's say your directory
looks like this:

$ ls -1
--one-file-system
a
b
c
|
|foo

Yes, that's a vertical bar (i.e. pipe) in the last two files.  Start
typing this:

$ echo rm ./

Then press the escape key followed by the asterisk:

$ echo rm ./<ESC>*

Your command line should now look like this:

$ echo rm ./--one-file-system ./a ./b ./c ./\| ./\|foo

Edit the line to create the desire command:

$ rm ./--one-file-system ./\| ./\|foo

Under Ubuntu, bash gives you some hints to try if it doesn't
understand the command:

$ rm --one-file-system
rm: unrecognized option `--one-file-system'
Try `rm ./--one-file-system' to remove the file `--one-file-system'.
Try `rm --help' for more information.

Either 'rm --help' or 'man rm' on Ubuntu will give you this:

<quote>
       To remove a file whose name starts with a '-', for example
'-foo', use one of these commands:

              rm -- -foo

              rm ./-foo
</quote>

Good luck and let us know what works for you.

Regards,
- Robert



More information about the PLUG mailing list