HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Deelete command
Operating System - HP-UX
1833187
Members
3262
Online
110051
Solutions
Forums
Categories
Company
Local Language
back
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
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- 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-12-2005 08:15 AM
05-12-2005 08:15 AM
Deelete command
Dear all
i need to delete some files that are older than a specific date, can someone tell me what is the command to do that ?
also what if these files are in folders ? and i want to remove these folders also that are older than specific date ?
Thanks in advance
i need to delete some files that are older than a specific date, can someone tell me what is the command to do that ?
also what if these files are in folders ? and i want to remove these folders also that are older than specific date ?
Thanks in advance
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2005 08:24 AM
05-12-2005 08:24 AM
Re: Deelete command
Check the man page for find.
Essentially something like this.
find . -mtime +N | xargs rm
This will search the current directory and subdirectories for files last modified N number of days ago and remove them.
Essentially something like this.
find . -mtime +N | xargs rm
This will search the current directory and subdirectories for files last modified N number of days ago and remove them.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2005 08:26 AM
05-12-2005 08:26 AM
Re: Deelete command
The key to what you are trying to do is the find command.
For example:
cd to desired starting directory
find . -type f -name 'myfile*' -mtime +30 -exec rm {} \;
This will remove all regular files (-type f) that match the pattern 'myfile*' that have not been modified in more than days.
I suggest that you replace the:
-exec rm {} \;
with a safer command such as:
-exec ls -l {} \;
until you get a better understanding of the find command.
Man find for details.
For example:
cd to desired starting directory
find . -type f -name 'myfile*' -mtime +30 -exec rm {} \;
This will remove all regular files (-type f) that match the pattern 'myfile*' that have not been modified in more than days.
I suggest that you replace the:
-exec rm {} \;
with a safer command such as:
-exec ls -l {} \;
until you get a better understanding of the find command.
Man find for details.
If it ain't broke, I can fix that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2005 08:26 AM
05-12-2005 08:26 AM
Re: Deelete command
What you are asking here is very dangerous! There are many OS files that fall into this category.
DO NOT DO THIS SYSTEM WIDE!
You can use the find command to find files that are older than a certain number of days. BEWARE, some OS files will qualify in this condition.
DO NOT DO THIS SYSTEM WIDE!
Do it in a relatively safe area, such as the users /home directory.
# cd /home/
# find . -mtime +100 -exec rm {} \;
The rm -f will delete the directories.
Again, you do this command from the root directory and you will wipe out your system!
A final statement that should be a given, make sure you have good backups! If you do this command incorrectly and do not have good backups and an ignite tape, you have a dead system!
Again, much care is to be taken!
-
DO NOT DO THIS SYSTEM WIDE!
You can use the find command to find files that are older than a certain number of days. BEWARE, some OS files will qualify in this condition.
DO NOT DO THIS SYSTEM WIDE!
Do it in a relatively safe area, such as the users /home directory.
# cd /home/
# find . -mtime +100 -exec rm {} \;
The rm -f will delete the directories.
Again, you do this command from the root directory and you will wipe out your system!
A final statement that should be a given, make sure you have good backups! If you do this command incorrectly and do not have good backups and an ignite tape, you have a dead system!
Again, much care is to be taken!
-
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP