File remove command?

Tom Christiansen tchrist at convex.COM
Mon Jun 17 23:02:43 AEST 1991


>From the keyboard of doug at jhunix.HCF.JHU.EDU (Douglas W O'neal):
:How about 
:find / -inum `ls -i foo | awk '{print $1}' -` -exec rm -f {} \; -print

Remember inumbers are unique to the file system.  You don't know that foo
is on the root file system.  This way you'll unnecessarily traverse the
whole file.  I might do this, at least on my system:

(assume $file is the name of the file, and valid)

find `df $file | awk 'NR ==2 {print $6}'` 	\
	-xdev 					\
	-inum `ls -i $file | awk '{print $1}'`	\
	-exec /bin/rm {} \;  			\
	-print

--tom
--
Tom Christiansen		tchrist at convex.com	convex!tchrist
		"So much mail, so little time."  



More information about the Comp.unix.shell mailing list