help removing a file

Rick Schubert rns at se-sd.SanDiego.NCR.COM
Sat Sep 8 03:04:19 AEST 1990


In <1990Sep5.180847.21767 at zaphod.mps.ohio-state.edu> harmon at function.mps.ohio-state.edu (Jim Harmon) writes:

>Could someone someone help me with removing a file. On our system we have a
>file that appears as zhang?evai.tex when doing a `ls` but a tab completion
>says it's zhangNevai.tex. I've tried putting a back slash in front of the ?
>and quoting the whole name. I even tried doing `rm -i *` and it matches
>zhangNevai.tex but says there's No such file or directory.

I've seen about 6-8 follow-ups to this question, and none gave a very
general solution (some might work with some versions of `ls' and/or
some shells and/or some versions of `find' some might work depending on what
the non-printable characters are, while others won't work at all, anywhere).

The most general solution is to execute (assuming you are in the directory
with the offending file):
          rm -ri .

Then `rm' will prompt you for each of the files in the current directory
and those under it (unfortunately, although if you answer "n" when it first
encounters the directory, `rm' will not traverse the subdirectory).
Answer "n" to all of those except the one(s) you want removed.
The key is to avoid generating the filename on the command line (with
or without wildcards).

I was surprised to see this question posted to comp.unix.admin, but I was
even more surprised at the poor quality of the answers.  But I don't mean
to start a flamefest.

-- Rick Schubert (rns at se-sd.sandiego.NCR.COM)



More information about the Comp.unix.admin mailing list