- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Remove files
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
Forums
Discussions
Discussions
Discussions
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
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
03-07-2008 02:12 AM
03-07-2008 02:12 AM
Remove files
i have 5000 files in one directory. I want to remove files except first 8 days files.
Waiting for your response.
Thanks & Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2008 02:52 AM
03-07-2008 02:52 AM
Re: Remove files
Try the following steps:
1) Create a new temporary directory say /var/new
#mkdir /var/new
2) move to the particular directory in which u want to remove the files.
# cd â dirnameâ
3) find the file which are 8 days old and copy to /var/new
#find . -xdev -type f -mtime -8 -exec cp /var/new
4) Delete the files in your dir
#rm â rf *
5) Copy back your 8 days old files to your directory.
#cp /var/new/* .
Regards
Davis Paul.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2008 02:54 AM
03-07-2008 02:54 AM
Re: Remove files
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2008 03:26 AM
03-07-2008 03:26 AM
Re: Remove files
check 'man find' - there you can see the options you can use, for example:
'find . -type f ! -mtime -365 -exec ll {} \;'
'find . -type f ! -mtime -365 -exec rm {} \;'
(this is for files older than 1 year - it's always good to check a syntax with a 'll' at the end, so you can check if it works like you want).
You have to decide if you want to delete files older or newer than a defined date.
HTH
Volkmar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2008 03:32 AM
03-07-2008 03:32 AM
Re: Remove files
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2008 04:49 AM
03-07-2008 04:49 AM
Re: Remove files
Instead of terminating the '-exec rm {}' with a semicolon, use a "+" character. The use of the semicolon means that ONE process will be spawaned for every argument. With the "+" character, multiple arguments will be passed to a very few (or even one) process.
Thus:
# find /tmp -type f -mtime +8 -exec rm {} \+
...is far, far faster than:
# find /tmp -type f -mtime +8 -exec rm {} \;
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2008 12:27 AM
03-10-2008 12:27 AM
Re: Remove files
find . -type f !_newer
man find for more detail about newer option.
HTH,
Art