The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to Delete Multi Directory and Files cthinh UNIX for Dummies Questions & Answers 5 05-08-2008 05:03 AM
Is there anyway to delete a directory that has more than 200mil files? plcyber UNIX for Advanced & Expert Users 4 06-01-2007 05: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 10:46 PM
CRON. How to delete files within a directory southoxon UNIX for Dummies Questions & Answers 1 08-24-2003 11:55 AM

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

Join Date: May 2008
Posts: 51
delete all but one files in a directory

what`s the script to do that? assuming my text file is "test.txt"
  #2 (permalink)  
Old 05-21-2008
penchal_boddu penchal_boddu is offline
Registered User
  
 

Join Date: Apr 2008
Location: Bangalore
Posts: 127
Hi

ls | grep -v test.txt | xargs rm


Thanks
Penchal
  #3 (permalink)  
Old 05-21-2008
aju_kup aju_kup is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 189
find /path/to/find -name "test.txt" | xargs rm
  #4 (permalink)  
Old 05-21-2008
penchal_boddu penchal_boddu is offline
Registered User
  
 

Join Date: Apr 2008
Location: Bangalore
Posts: 127
Hi,

I think find command will search recursively throeugh all the directories.

either maxdepth or prune option must be used.

Please correct me if iam wrong.

Thanks
Penchal
  #5 (permalink)  
Old 05-21-2008
aju_kup aju_kup is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 189
Yes, It will search through all sub directories also

if u want delete in all sub directories then no need to use any other option with find
  #6 (permalink)  
Old 05-21-2008
finalight finalight is offline
Registered User
  
 

Join Date: May 2008
Posts: 51
oh..I don't need to find the subdirectories..only that particular directory will do..
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 09:37 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