- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Removes 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
05-31-2006 12:20 PM
05-31-2006 12:20 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2006 12:30 PM
05-31-2006 12:30 PM
Solutionfind /path -mtime +30 -type f -exec rm {} \;
Be carefull when you specify the time, if you specify:
-mtime 30 - Exactly 30 days ago
-mtime -30 - From 30 days ago until now (dangerous)
-mtime +30 - 30 or more days ago (correct)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2006 12:31 PM
05-31-2006 12:31 PM
Re: Removes files
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2006 12:55 PM
05-31-2006 12:55 PM
Re: Removes files
should i always give complete path ?
1) what if i'm in current drectory and
want to delete files those are older than 30 days in current drectory ? Still i need to specify full path name ?
2) what is the usage of " -type f ", how can i delete only *.log , i dont have manual for find in my system.
HELP THANKS.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2006 07:56 PM
05-31-2006 07:56 PM
Re: Removes files
1) what if i'm in current directory and
want to delete files those are older than 30 days in current drectory ? Still i need to specify full path name ?
No, you can do a 'find .' - note: find always also search directories under this dir. I not yet seen an option so find doesn't do that.
2) what is the usage of " -type f ", how can i delete only *.log , i dont have manual for find in my system.
'-type f' ensures that you don't erase directories
To delete *.log:
find /path -mtime +30 -type f -name "*.log" -exec rm {} \;
To be sure that you don't delete wrong files, you can do a
find /path -mtime +30 -type f -name "*.log" -exec ll {} \;
first.
HTH
Volkmar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2006 08:39 PM
06-01-2006 08:39 PM
Re: Removes files
-atime n True if the file access time subtracted from
the initialized time is n-1 to n multiples of
24 h. The initialization time shall be a time
between the invocation of the find utility and
the first access by that invocation of the find
utility to any file specified by its path
operands. The access time of directories in
pathname_list is changed by find itself.
-mtime n True if the file modification time subtracted
from the initialization time is n-1 to n
multiples of 24 h. The initialization time
shall be a time between the invocation of the
find utility and the first access by that
invocation of the find utility to any file
specified in its path operands.
-ctime n True if the time of last change of file status
information subtracted from the initialization
time is n-1 to n multiples of 24 h. The
initialization time shall be a time between the
invocation of the find utility and the first
access by that invocation of the find utility
to any file specified by its path operands.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2006 11:04 PM
06-01-2006 11:04 PM
Re: Removes files
For example, the find command (in English) is at:
http://docs.hp.com/en/B2355-90689/find.1.html
Also: please take the time to provide points to those folks who answer your questions. This will help to continue your receiving responses fom the extremely knowledgable folks (not me, I just lurk here mostly) who read this forum.
"I have assigned points to 14 of 86 responses to my questions."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2006 03:12 AM
06-02-2006 03:12 AM
Re: Removes files
No, you can do a 'find .' - note: find always also search directories under this dir. I not yet seen an option so find doesn't do that.
<<
but i dont want to delete files in subdirectories..how to limit it to current directory only.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2006 04:23 AM
06-02-2006 04:23 AM
Re: Removes files
find /path -mtime +30 -type f -exec ll {} \;
('ctime' never seems to give the right results)
Giving 'rm' to a command that's going to generate a lot of filenames is always risky.
"find" is designed to be recursive. One thing you might do is run find with ls, send the output to a file
find /path -mtime +30 -type f -exec ls {} \; > flist
Then edit the file to delete subdirectory files, then do something like (in ksh)
for file in $(cat flist)
do
rm $file
done