LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices



Reply
 
Search this Thread
Old 09-14-2008, 05:02 AM   #1
dina3e
Member
 
Registered: Mar 2008
Location: Bangalore
Distribution: Enterprise Red Hat linux
Posts: 98

Rep: Reputation: 16
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 ?
 
Old 09-14-2008, 05:20 AM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728
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)
 
Old 09-14-2008, 07:01 AM   #3
lipun4u
Member
 
Registered: Sep 2008
Location: Mumbai, india
Distribution: ubuntu and hp-unix
Posts: 118

Rep: Reputation: 15
there is an another command called "unlink" . but it can only delete files not directories .
 
Old 09-14-2008, 12:59 PM   #4
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,139

Rep: Reputation: 322Reputation: 322Reputation: 322Reputation: 322
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?

Last edited by btmiller; 09-21-2008 at 12:04 AM. Reason: typo removal
 
Old 09-20-2008, 10:58 PM   #5
dina3e
Member
 
Registered: Mar 2008
Location: Bangalore
Distribution: Enterprise Red Hat linux
Posts: 98

Original Poster
Rep: Reputation: 16
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??
 
Old 09-20-2008, 11:19 PM   #6
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 59
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.
 
Old 09-20-2008, 11:49 PM   #7
John VV
Guru
 
Registered: Aug 2005
Posts: 13,214

Rep: Reputation: 1772Reputation: 1772Reputation: 1772Reputation: 1772Reputation: 1772Reputation: 1772Reputation: 1772Reputation: 1772Reputation: 1772Reputation: 1772Reputation: 1772
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
 
Old 09-22-2008, 08:47 AM   #8
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,043

Rep: Reputation: 375Reputation: 375Reputation: 375Reputation: 375
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.

Last edited by i92guboj; 09-22-2008 at 09:02 AM.
 
Old 10-01-2008, 04:06 AM   #9
dina3e
Member
 
Registered: Mar 2008
Location: Bangalore
Distribution: Enterprise Red Hat linux
Posts: 98

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by John VV View Post
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Remove whitespace in file and directory names using bash TheFutonEng Programming 14 02-26-2012 01:35 PM
Home Jail Folder Structure like Gobolinux Directory Structure luispt Linux - General 3 07-26-2008 07:46 PM
Thank every one. PATHCHANGER sript file Add/Remove directory to path! icecoolcorey Programming 1 06-13-2008 02:42 AM
LXer: Four ways to extract the current directory name LXer Syndicated Linux News 0 11-06-2007 02:30 PM
remove directory info from tar file splunk Linux - Software 2 08-22-2007 04:24 PM


All times are GMT -5. The time now is 04:46 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration