Help answer threads with 0 replies.
Go Back > Forums > Enterprise Linux Forums > Linux - Enterprise
User Name
Linux - Enterprise This forum is for all items relating to using Linux in the Enterprise.


  Search this Thread
Old 01-15-2007, 12:36 AM   #1
LQ Newbie
Registered: Oct 2006
Posts: 14

Rep: Reputation: 0
script for deleting .dat files which > 5 mb from a directory and its subdirectory


can you tell me how to write a script which will remove all the .DAT files which are greater than 5 MB form a directory and its sub-directory ?

Thanks in advance.............

anindya bhattacharjee
Old 01-15-2007, 01:28 AM   #2
LQ Guru
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled
Umm something like
find /start/directory -name *.DAT -type f -size +5M -print | xargs /bin/rm -f
might find the files (test it first by only taking in the 'find' part, i.e. don't write '-print' nor anything after it -- if it lists correct files, then use the whole line). That's just off the top of my head, so be aware. Read
man find
for more instructions.
Old 01-15-2007, 11:38 PM   #3
LQ Newbie
Registered: Oct 2006
Posts: 14

Original Poster
Rep: Reputation: 0
deleting problem solved


thanks for your reply . after doing some changes in your command , I am now able to delete those files .

anindya bhattacharjee

Last edited by anindyabhattacharjee; 01-15-2007 at 11:40 PM.


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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing File Permission in a FTP directory to prevent deleting of files shawnbishop Linux - Software 3 01-10-2006 05:41 AM
Deleting unwanted files from any directory without reading each Karthikeyan Gurusamy Linux - Newbie 3 12-24-2005 01:48 AM
deleting all *.m3u files in a directory+subdir? minm Linux - Newbie 5 10-12-2004 03:31 PM
Deleting Windows Index.dat and other 'spyware' from Linux aweir14150 Linux - General 5 03-04-2004 01:54 PM
Script for deleting files based on date MaverickApollo Linux - General 3 02-03-2004 07:54 PM > Forums > Enterprise Linux Forums > Linux - Enterprise

All times are GMT -5. The time now is 09:42 AM.

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