LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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, 04: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, 04:20 AM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
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, 06: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, 11:59 AM   #4
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,290

Rep: Reputation: 378Reputation: 378Reputation: 378Reputation: 378
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-20-2008 at 11:04 PM. Reason: typo removal
 
Old 09-20-2008, 09: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, 10:19 PM   #6
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 63
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, 10:49 PM   #7
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,624

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
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, 07:47 AM   #8
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,083

Rep: Reputation: 405Reputation: 405Reputation: 405Reputation: 405Reputation: 405
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 08:02 AM.
 
Old 10-01-2008, 03: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



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 12:35 PM
Home Jail Folder Structure like Gobolinux Directory Structure luispt Linux - General 3 07-26-2008 06:46 PM
Thank every one. PATHCHANGER sript file Add/Remove directory to path! icecoolcorey Programming 1 06-13-2008 01:42 AM
LXer: Four ways to extract the current directory name LXer Syndicated Linux News 0 11-06-2007 01:30 PM
remove directory info from tar file splunk Linux - Software 2 08-22-2007 03:24 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:06 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration