The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
delete all but one files in a directory finalight Shell Programming and Scripting 10 05-21-2008 03:51 AM
Is there anyway to delete a directory that has more than 200mil files? plcyber UNIX for Advanced & Expert Users 4 06-01-2007 04:28 PM
Delete Some Old files from Particular Directory siva80_cit Shell Programming and Scripting 2 12-11-2006 06:47 AM
delete files in specific directory legato Shell Programming and Scripting 2 03-29-2006 09:46 PM
CRON. How to delete files within a directory southoxon UNIX for Dummies Questions & Answers 1 08-24-2003 10:55 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-06-2008
cthinh cthinh is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 9
Question How to Delete Multi Directory and Files

I have a subdirectory which has many child directories and files in it. How can i delete them through a list (txt, rtf. xls , or any file extension) which is created by me. I can not manual delete one by one because it almost over 300 directory and over 4000 files. Any one know please help me?
  #2 (permalink)  
Old 05-06-2008
krishmaths krishmaths is offline
Registered User
  
 

Join Date: Sep 2006
Location: Mysore, India
Posts: 191
find command with option user may help.

Execute this to see if these are the files you want to delete
Code:
find . -user <your_user_name> -exec ls -l {} \;
and then remove them using the below command
Code:
find . -user <your_user_name> -exec rm -f {} \;
However, be very sure before using the rm command given above. Verify that you are not deleting more files than what you actually need.
  #3 (permalink)  
Old 05-06-2008
cthinh cthinh is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 9
But the problem is how can i choose the list of files i want to delete.
  #4 (permalink)  
Old 05-06-2008
frank_rizzo frank_rizzo is offline Forum Advisor  
Resident BOFH
  
 

Join Date: Dec 2007
Posts: 425
add
Code:
-name \*.txt
to the find.
  #5 (permalink)  
Old 05-08-2008
cthinh cthinh is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 9
I begin with create a a file:

#touch list.txt
#nano list.txt

and insert the name of folder i want to delete into this file then i run

#find -name \list.txt

but it didn't work out. Please help. I've just familiar with UNIX so i don't know much about it. Step by step is much appreciated.
  #6 (permalink)  
Old 05-08-2008
krishmaths krishmaths is offline
Registered User
  
 

Join Date: Sep 2006
Location: Mysore, India
Posts: 191
To read folder names from list.txt and remove them, you can write a simple script like:
Code:
while read line
do
 rm -R $line
 echo "Folder $line removed"
done<list.txt
Caution: You can place a check whether you are removing the intended folders only, by placing an echo and commenting rm.
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 04:20 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0