File remove command?

Arthur S. Kamlet ask at cbnews.cb.att.com
Sun Jun 16 07:09:40 AEST 1991


In article <3431 at crdos1.crd.ge.COM> davidsen at crdos1.crd.ge.com (bill davidsen) writes:
>Has anyone written a remove command which will unlink all links to a
>file inode when the command is issued on any one name?

The heart of this command is to find the inumber;
then remove all files in that filesystem with that inumber.


For SVR3 Unixes - at least - you can find the inumber by an ls -lai

$ ls -lai junk

  397 -rw-r--r--   1 ask      user         571 Mar  5 15:07 junk


So, you now want to remove all files with inumber 397

You need to know the root directory of your filesystem

(use the /etc/mount or df command to find out if you are unsure)

Then do a find and remove all occurences of that inumber

$ cd /usrc    # /usrc is the filesystem containing the files

$ find  .  -inum 397 -exec rm {} \;


Caution:  inumbers are not unique in your system; only in your
          filesystem.   So it's a very bad idea to do a
                        find / -inum 397 .....

These are the basics; you might want to put these together in a
script and add some tests.
-- 
Art Kamlet  a_s_kamlet at att.com  AT&T Bell Laboratories, Columbus



More information about the Comp.unix.shell mailing list