req: New feature to rm? Remove file by the inode number

Garance A Drosihn drosih at rpi.edu
Thu May 5 13:02:06 PDT 2005


At 2:19 PM +0300 5/5/05, Erik Udo wrote:
>I couldn't find a way to remove files that had scandic/non-printable
>letters, then i remembered ls showed inode number of the file. Is it
>possible to remove the file by the inode number? It would be a
>useful feature :)

It would be a bad feature, at least for the problem you are
trying to solve.

You are trying to remove one specific filename from one specific
directory.  It is possible to link multiple filenames to the
exact same file (inode).  If a file has multiple links to it,
then you would want to remove only the filename you're looking
at, and not all filenames in the filesystem which might have
the same inode.

Other solutions, with 'find' or 'rm -i ./*', are more correct
for the situation you are looking at.  Note that if a file only
has *some* unprintable characters, and also has some standard
characters, then you can use pattern-matching to reduce how
many fines would be matched by 'rm -i'.  Something like:
     rm -i ./*blah*

I have been in similar situations to what you're describing, and
I've never had to do more than pick a reasonable filename pattern
and combine it with -i (-i for "interactive", so it prompts you
for each file before removing it).

-- 
Garance Alistair Drosehn            =   gad at gilead.netel.rpi.edu
Senior Systems Programmer           or  gad at freebsd.org
Rensselaer Polytechnic Institute    or  drosih at rpi.edu


More information about the freebsd-hackers mailing list