I have lots of subfolders inside a particular folder which in turn contains lots of smaller files. They are created programmatically and so I do not know how many of them are there inside.
I decided to remove all these sub-folder and files and so I issued the command,
rm -rf foldername/
However, the rm command is taking so much time to execute which I believe is perfectly normal since it has to unlink all the files.
But, I decided to check if the size of this folder is getting reduced by issuing the command,
du -sh foldername/
However, the above command gives me the error as,
du: cannot access `foldername/file': No such file or directory
Why is this error happening?
du
command. Thanks for this wonderful explanation. So if a file is unlinked byrm
command, will the file be still accessible using its path or the descriptor? – Ramesh Jun 28 '14 at 22:38rm
, it is no longer accessible via its path (that's what “unlink” means). The file can still be accessed by a process that has it open, if there is one.du
doesn't open files apart from directories; if it has a directory open whilerm
deletes it, it can still read from it, but the read will return “no more entries” sincerm
has removed them all. The file could still be accessed by other names (hard links) if it has them. – Gilles 'SO- stop being evil' Jun 28 '14 at 22:58