//View Tip #232
» Remove duplicate files
» Find and Grep
» Find and remove core files
» Find files by mime-type
Similar Tips
» Delete old files» Remove duplicate files
» Find and Grep
» Find and remove core files
» Find files by mime-type
Latest tips by RSS
Click here to subscribe
Follow Shell-Fu on Twitter
Click here to follow
Follow Shell-Fu on identi.ca
Click here to follow
To delete a file who's file name is a pain to define (eg. ^H^H^H) find it's inode number with the command "ls -il". Use the line below to find and delete the file.
find . -inum 12345 | xargs rm
Comments
Add your comment
Or use:
find . -inum 12345 -print0 | xargs -0 rm
if there is a space in the file-name, and you're not in the hurry.
find . -inum 12345 -print0 | xargs -0 rm
if there is a space in the file-name, and you're not in the hurry.
Posted 2008-10-21 11:17:29
Actually,
find -inum 12345 -exec rm {} \;
uses two commands.
find -inum 12345 -delete
doesn't.
find -inum 12345 -exec rm {} \;
uses two commands.
find -inum 12345 -delete
doesn't.
Posted 2009-02-06 10:28:48
Touché Paul. I like how Nathan wrote a nice long comment complaining that the original submission ran two commands when his did as well. Granted, piping find output is slower than using the exec option, but it's still two commands. ^.^
Posted 2009-03-10 07:44:41
The first option (with xargs) is DANGEROUS.
If the file name contains white spaces then you can end up with xargs splitting at the spaces and passing different names to those find found.
If the file name contains white spaces then you can end up with xargs splitting at the spaces and passing different names to those find found.
Posted 2009-06-15 12:21:39
i believe you are a good writer, but have you erver thought to write some special artcals for peopel who likes shopping very much.
Posted 2010-07-15 22:41:17


What you have:
find . -inum 12345 | xargs rm
What is faster and uses only one command:
find -inum 12345 -exec rm {} \;
Proof just time them. On my system I see:
xxx@xxx-laptop:~/Desktop$ time find -name xxx -exec rm {} \;
real 0m0.009s
user 0m0.004s
sys 0m0.004s
xxx@xxx-laptop:~/Desktop$ time find -name xxx | xargs rm
real 0m0.014s
user 0m0.012s
sys 0m0.004s
xxx@xxx-laptop:~/Desktop$