- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Delete files using time stamp
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
тАО11-03-2008 11:09 PM
тАО11-03-2008 11:09 PM
I want to delete the files of 2004 from my directory?Is there any way to remove the files using time stamp?
Could you please help me to find out a solution?
Regards
Muktha
Solved! Go to Solution.
- Tags:
- find
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-03-2008 11:33 PM
тАО11-03-2008 11:33 PM
Re: Delete files using time stamp
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1133772
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1254376
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1204021
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1053038
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1107387
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1221713
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1222831
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1227620
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1227469
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-04-2008 05:23 AM
тАО11-04-2008 05:23 AM
SolutionThe following solutions assume the you want to REMOVE any file last modified in 2004. To test, change 'rm' to 'echo'.
# cd /path
# ls -al|awk '/^-/ && $8~2004 {print $NF}'|xargs -i rm {}
This works for the specified directory and not for files in subordinate directories.
If you do want to descend into all subordinate directories, simply use:
# cd /path
# find . -type f -exec ls -al {}+|awk '/^-/ && $8~2004 {print $NF}'|xargs -i rm {}
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-04-2008 06:20 AM
тАО11-04-2008 06:20 AM
Re: Delete files using time stamp
In keeping with TMTOWTDI, here's a pure Perl solution you could use. Change the value of 2004 to any year you want, *including* the current year.
Change the 'print' to 'unlink' and instead of actually printing the file names you will *remove* them:
# perl -MFile::Find -le '$Y=2004;find(sub{-f $_ && ((localtime((stat(_))[9]))[5]+1900==$Y) && print $File::Find::name},@ARGV)' /path
You can also pass multiple paths as arguments or a dot ('.') to signify (of course) the current directory.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-04-2008 06:48 AM
тАО11-04-2008 06:48 AM
Re: Delete files using time stamp
To remove dated files. Can be modified to remove sized files as well.
# touch -amt 200504150000 /tmp/ref1
# touch -amt 200802282359 /tmp/ref2
# find /opt/mtmc/ibs/import/reject -xdev -type f -newer /tmp/ref1 -a ! -newer /tmp/ref2 -exec rm {} \+
This will remove files that are newer (more recently modified) than April 15 at 0000 AND NOT newer than Feb, 28th 2359 of this year
time Use the specified time instead of the current time.
The option argument is a decimal number of the form
[[CC]YY]MMDDhhmm[.SS]
where each two digits represents the following:
CC The first two digits of the year.
YY The second two digits of the year.
MM The month of the year (01-12).
DD The day of the month (01-31).
hh The hour of the day (00-23).
mm The minute of the hour (00-59).
SS The second of the minute (00-61).
If neither CC nor YY is given, the current year is
assumed. If YY is specified, but CC is not, CC is
derived as follows: (taken into account the local time
factor)
If YY is: CC becomes:
_______________________
69-99 19
00-68 20
If the resulting time value precedes the Epoch
(00:00:00 January 1, 1970 Greenwich Mean Time), touch
exits immediately with an error status.
The range for SS is 00 through 61 rather than 00
through 59 to accommodate leap seconds. If SS is 60 or
61, and the resulting time, as affected by the TZ
environment variable, does not refer to a leap second,
the resulting time is one second after a time where SS
is 59. If SS is not given a value, it is assumed to be
0.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-05-2008 11:26 PM
тАО11-05-2008 11:26 PM