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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how to delete content in a file (delete content only) kittusri9 Shell Programming and Scripting 5 05-15-2008 10:12 AM
delete in c++ nandlal High Level Programming 4 02-02-2008 09:48 AM
C++ = new and delete arun.viswanath High Level Programming 3 09-13-2005 07:16 PM
delete lesstjm UNIX for Dummies Questions & Answers 3 11-08-2001 12:24 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 05-06-2008
Registered User
 

Join Date: Apr 2008
Posts: 20
Need Help to delete Smartly...!!!

There is a Directory...Master(say)

under this there are further sub-directories...
(say) A B C D E,etc

These sub-directories contains files in the format somestring_20070502{yyyymmdd}format.dat.

I want to delete files of month's SMARTLY w/o getting into each sub-directory.

Note Each each day i receive files in the sub-folders, eveyr month i need to delete the files manually.
Can you help me in writing the script(or smart one-liners will also do) to ease the tasks...!!!

Cheers
Kunal
Reply With Quote
Forum Sponsor
  #2  
Old 05-06-2008
 

Join Date: May 2008
Location: Sydney, Australia
Posts: 917
Which ones exactly do you want to delete? Only those for a specific date? Would this not do what you require?

Code:
rm /Master/?/*_20070502.dat
Reply With Quote
  #3  
Old 05-06-2008
Registered User
 

Join Date: Jul 2006
Posts: 189
find . -name \*.dat -atime +30 -print | xargs rm
Reply With Quote
  #4  
Old 05-06-2008
Registered User
 

Join Date: Apr 2008
Posts: 20
rm /Master/?/*_20070502.dat is not working...

under Master I want to delete all files *.20070502.dat from all sub-folders.
Reply With Quote
  #5  
Old 05-06-2008
 

Join Date: May 2008
Location: Sydney, Australia
Posts: 917
Change the _ to a . then??

I'm presuming /Master is off the root directory. If not, then obviously you will need to supply the correct path, or cd into it first and just use rm ?/*.20070502.dat.

I'm also presuming that the directories under Master have just single-letter names. If not, replace ? with *.
Reply With Quote
  #6  
Old 05-06-2008
Registered User
 

Join Date: Apr 2008
Posts: 20
/home/users/Master - under this there are 5 sub-directories which contains
string_yyyymmdd.dat files

I want to remove the yyymmdd files from all sub-directores..

above is still not working....
Reply With Quote
  #7  
Old 05-06-2008
 

Join Date: May 2008
Location: Sydney, Australia
Posts: 917
You are contradicting yourself. On your previous post you said *.20070502.dat, but now you are saying *_20050702.dat. Are you sure which one is correct?

Presuming it is _, This should work:

Code:
rm /home/users/Master/*/*_20070502.dat
Or using a variation of aju_kup's solution:

Code:
find /home/users/Master/* -name '*_20070502.dat' | xargs rm
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 12:21 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0