LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   how many different ways we can remove the file from a directory structure. (https://www.linuxquestions.org/questions/linux-general-1/how-many-different-ways-we-can-remove-the-file-from-a-directory-structure-669817/)

dina3e 09-14-2008 04:02 AM

how many different ways we can remove the file from a directory structure.
 
Except the rm command can we remove the file from the directory structure ?

I've doubt regarding can we redirect the desire directory structure to the /dev/null or /dev/zero so that all the content is as null..

how can i achieve this things ?

pixellany 09-14-2008 04:20 AM

What problem are you trying to solve?

You can't re-direct a directory structure to /dev/null. You re-direct DATA (to any number of places, including /dev/null)

lipun4u 09-14-2008 06:01 AM

there is an another command called "unlink" . but it can only delete files not directories .

btmiller 09-14-2008 11:59 AM

Given thaqt directories are just special files, I suppose you could just edit them with debugfs or the like, however this is a really bad idea in all but the most desperate of circumstances (e.g. trying to recover a seriously hosed filesystem), and it should never, ever be done on a mounted filesystem.

Like pixellany asked, what exactly are you trying to do that you can't use rm?

dina3e 09-20-2008 09:58 PM

The thing is that there is some million files in a directory , my i am trying to remove all these but by using rm it takes lots of time .

so can it possible in the fraction of second to this??

Mr. C. 09-20-2008 10:19 PM

The slow performance is not the rm(1) command, it is the updating of the directory itself, which is a slow operation. Changes have to be written to the disk upon each unlink(2) operation.

John VV 09-20-2008 10:49 PM

try this
cd / to folder ( cd /home/me/tempfiles1 )
rm -I *

see : "rm --help" or "man rm"
there also is
shred -n 1 -u *
but this will take a while

i92guboj 09-22-2008 07:47 AM

The chosen filesystem has a big impact on this. Some filesystems are faster than others at deleting files. You can't just redirect a tree to null nor anything like that. The files need to be unlinked from the filesystem one by one, directories can't be deleted unless the only files inside them are . and ..

rm is as fast as it can be, if the file list is really really long, you can use xargs to work around it.

dina3e 10-01-2008 03:06 AM

Quote:

Originally Posted by John VV (Post 3286912)
try this
cd / to folder ( cd /home/me/tempfiles1 )
rm -I *

see : "rm --help" or "man rm"
there also is
shred -n 1 -u *
but this will take a while



yes, shred is more secure to use for the remove the file system.

Thank you


All times are GMT -5. The time now is 06:11 PM.