- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Delete 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
06-02-2003 09:12 AM
06-02-2003 09:12 AM
[
02-June-2003 Monday , as of today i'll be having the following list of files.
(Mon thru Friday)
History.dat052603
History.dat052703
History.dat052803
History.dat052903
History.dat053003
History.dat060203 ]
..
..
..
..
Delete Files
History.dat060903
..
My requirement is , on every monday i need to delete the input files those i received week before last week.
i.e in the above case , on 06/09/03 i need to delete files received from 05/26/03 thru 05/30/03.
Hope i'm making myself clear.
How to get the last modified date of particular file OR is there any simple solution for my requirement.
Thanks in Advance.
Raj !!!!!!!!!!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2003 09:17 AM
06-02-2003 09:17 AM
Re: Delete Files
find /directory -type f -name History.dat* -mtime +5 -exec rm {} \;
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2003 09:26 AM
06-02-2003 09:26 AM
Re: Delete Files
# find /dir_name -name History.dat* -type f -xdev -mtime +7 -exec rm {} \;
This will delete all files which was not modified for the last 7 days. If you want to include last accessed option too, then add -atime with find command. If you want to print a list of files which were deleted, then inlcude -exec ll {} \; with find command.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2003 09:31 AM
06-02-2003 09:31 AM
Re: Delete Files
Try the following:
find /dirname -name History.dat* -type f -mtime +5 -exec rm {} \;
You can add this line to a cleanup/housekeeping script or create a script that contains this line and add the script to the user's crontab.
Regards,
DR
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2003 09:45 AM
06-02-2003 09:45 AM
Re: Delete Files
when i give the above it gives me error saying,
"find: missing conjunction"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2003 09:47 AM
06-02-2003 09:47 AM
Re: Delete Files
Put the file name - History.dat* in quotes:
# find ..options ..-name 'History.dat*' ..options
That will solve the issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2003 09:48 AM
06-02-2003 09:48 AM
Re: Delete Files
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2003 09:50 AM
06-02-2003 09:50 AM
Re: Delete Files
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2003 09:51 AM
06-02-2003 09:51 AM
Re: Delete Files
Using an 'find' expression with a wildcard should be quoted to prevent the shell from expanding it:
# find /home/dmeload/CMI -name "History.dat*" -type f -xdev -mtime +7 exec rm {} \;
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2003 09:58 AM
06-02-2003 09:58 AM
Re: Delete Files
$ find /home/dmeload/CMI -name "History.dat*" -type f -xdev -mtime +7 exec rm {} \;
Both throws same error.
:-(
"find: missing conjunction"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2003 10:02 AM
06-02-2003 10:02 AM
Re: Delete Files
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2003 10:02 AM
06-02-2003 10:02 AM
Re: Delete Files
$ uname -a
HP-UX dmeserv B.11.00 U 9000/899 1459612391 unlimited-user license
Is anything to do with this ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2003 10:04 AM
06-02-2003 10:04 AM
Re: Delete Files
You need a minus sign in front of "exec":
-exec rm {} \;
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2003 10:04 AM
06-02-2003 10:04 AM
Re: Delete Files
Also, the uname output doesn't have ny impact on your find command. What type of shell are you in?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2003 10:04 AM
06-02-2003 10:04 AM
Re: Delete Files
I'm not using -exec
This is how i'm giving,
$ find /home/dmeload/CMI -name 'History.dat*' -type f -xdev -mtime +7 exec rm {} \;
$ find /home/dmeload/CMI -name "History.dat*" -type f -xdev -mtime +7 exec rm {} \;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2003 10:06 AM
06-02-2003 10:06 AM
Re: Delete Files
A man find would tell you all of this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2003 10:06 AM
06-02-2003 10:06 AM
Re: Delete Files
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2003 10:06 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2003 10:36 AM
06-02-2003 10:36 AM
Re: Delete Files
-exec solved the issue.
Clay Stephenson: I'm a new bee to unix..also i needed to solve this in quick time.. so didnt have time to look at manuals...please dont mind...
anyways....thanks all.
Meet you all with next query
;-)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2003 10:41 AM
06-02-2003 10:41 AM
Re: Delete Files
With regard to "manuals", whether or not you're new to Unix or old friends with it, the man pages are one of the greatest sources of information at your disposal. Don't ever *not* take a minute to look.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2003 10:42 AM
06-02-2003 10:42 AM
Re: Delete Files
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2003 11:09 AM
06-02-2003 11:09 AM
Re: Delete Files
Another way to get information (after checking the man pages) is to do a search in the forum. You will see the amount of information you'll find in the forums and most of the time you will understand them better than the man pages.
Welcome to the UNIX world.
Regards,
DR
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2003 02:55 AM
06-03-2003 02:55 AM
Re: Delete Files
I think a cron job that does a simple "find" should do it. If they are all in a directory called fred, say, then something like
find /fred -name Hist\* -ctime +7 -print -exec rm {} \;
You'd better experiment without the "-exec rm {} \;"
to make sure you're getting the files you want.
Regards,
Garry Ferguson