- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Find command to delete files in dir
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-06-2010 12:59 AM
тАО05-06-2010 12:59 AM
Request proper command to delete the files in directory.
scenario : keep 6 months files till date & delete all the files 6 months before.
Thanks to confirm..
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-06-2010 01:10 AM
тАО05-06-2010 01:10 AM
Re: Find command to delete files in dir
is this command will work
find . -mtime +180 -exec rm -rf {} \;
regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-06-2010 01:15 AM
тАО05-06-2010 01:15 AM
Re: Find command to delete files in dir
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-06-2010 03:41 AM
тАО05-06-2010 03:41 AM
Re: Find command to delete files in dir
I would not use the above command until you clarify your requirements. Do you want all files *and* directories *and* subdirectories deleted that are more than 180 days old? If not, you will need to add more options. For example, to delete only ordinary files, add -type d to the find command.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-06-2010 03:47 AM
тАО05-06-2010 03:47 AM
Re: Find command to delete files in dir
Maybe "-type f" ????
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-06-2010 04:05 AM
тАО05-06-2010 04:05 AM
Re: Find command to delete files in dir
Command to list the files:-
find . -mtime +180 -type f -print
Gudluck
Prasanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-06-2010 05:25 AM
тАО05-06-2010 05:25 AM
Re: Find command to delete files in dir
I want to keep the files of six months till date.
example: today is may6 and till november 6 2009 i have keep all of them. and to remove all files NOT directory.
In my scenario there are many files under many directories , i dont want to delete the directories. and my files are from 2007 & 2008 etc. so i have keep latest 6 month data & delete only files from directories & other directories
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-06-2010 05:28 AM
тАО05-06-2010 05:28 AM
Re: Find command to delete files in dir
find /startdir -type f -mtime +180 -exec rm {} \;
- or -
find /startdir -type f -mtime +180 |xargs rm
The second form cuts down a bit on resource usage.
And you should test first by replacing the "rm" with "ll".
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-06-2010 05:35 AM
тАО05-06-2010 05:35 AM
Re: Find command to delete files in dir
Thanks a lot for your quick response...
I got it... :)
regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-06-2010 05:36 AM
тАО05-06-2010 05:36 AM
Re: Find command to delete files in dir
if i wanna exclude particular directory then what will be the syntax
regards