[comp.unix.questions] Filenames and Inode Numbers

ritter@cs.msstate.edu (Thomas H. Ritter) (07/27/89)

Rick Geymont <GU.GEYMONT%SCIENCE.UTAH.EDU@wasatch.utah.edu> writes:

>The easiest way I have found to remove files with special characters in the
>name is to do the following:
>do an 'ls -i' and get the inode number
>type 'find . -inum # -exec rm {} \;' where # is the inode number.
>
>Works every time...
>

Well almost every time.  Our Suns have the -inum option but
our Unisys 5000 SYSV3.1 does not. The interesting thing is
that the following :

      rm - -name

works and removes the file called "-name" BUT gives an      
an error anyway.

BTW, I can do an ls -i and see the inode information but
what other ways could I remove a file based on inode number?


Tom Ritter
ritter@cs.msstate.edu

guy@auspex.auspex.com (Guy Harris) (07/28/89)

>Well almost every time.  Our Suns have the -inum option but
>our Unisys 5000 SYSV3.1 does not.

Your Suns *document* the "-inum" option but your Unisys does not, I
assume; this is different from "your Suns have the '-inum' option but
your Unisys does not."  "-inum" has been in "find" since V7, but the
first time it was actually *documented* was in some BSD release, and the
SunOS documentation picked it up from there; the folks who did S5 didn't
bother documenting it.  Try "-inum" on your Unisys and see if it
works....

>The interesting thing is that the following :
>
>      rm - -name
>
>works and removes the file called "-name" BUT gives an      
>an error anyway.

That should work without a complaint on your Suns, since their "rm"
command is BSD-derived and thus supports "-" as an option to tell it
"everything after this is a file name, even if it begins with '-'".

Your Unisys box should have a similar option, named "--", since the S5R3
"rm" uses "getopt" to parse its arguments and "getopt" handles "--", so
try

	rm -- -name

there.

bsa@telotech.UUCP (Brandon S. Allbery) (08/01/89)

In article <20373@adm.BRL.MIL>, ritter@cs (Thomas H. Ritter) writes:
+---------------
| Rick Geymont <GU.GEYMONT%SCIENCE.UTAH.EDU@wasatch.utah.edu> writes:
| >The easiest way I have found to remove files with special characters in the
| >name is to do the following:
| >do an 'ls -i' and get the inode number
| >type 'find . -inum # -exec rm {} \;' where # is the inode number.
| 
| Well almost every time.  Our Suns have the -inum option but
| our Unisys 5000 SYSV3.1 does not.
| 
| BTW, I can do an ls -i and see the inode information but
| what other ways could I remove a file based on inode number?
+---------------

rm `/etc/ncheck -i ...`

++Brandon
-- 
-=> Brandon S. Allbery @ telotech, inc.   (I do not speak for telotech.) <=-
Any comp.sources.misc postings sent to this address will be DISCARDED -- use
allbery@uunet.UU.NET instead. My boss doesn't pay me to moderate newsgroups.
** allbery@NCoast.ORG ** uunet!hal.cwru.edu!ncoast!{allbery,telotech!bsa} **