- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: delete the files with date wise
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
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
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
02-26-2014 03:52 AM - last edited on 02-26-2014 07:42 PM by Lisa198503
02-26-2014 03:52 AM - last edited on 02-26-2014 07:42 PM by Lisa198503
delete the files with date wise
i want to delete the files with date wise, please share the command
example
-rwxrwxrwx 1rajesh users 261 Oct 1 2010 vgspace
-rwxr-xr-x 1rajesh users 512 Aug 11 2011 old
-rwxrwxrwx 1rajesh users 861 Aug 11 2011 bdf.txt
i want to delete Oct 1 2010 file. what is the command
P.S. This thread has been moved from HP-UX>System Administration to HP-UX > languages. -HP Forum Moderator
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2014 07:10 AM
02-26-2014 07:10 AM
Re: delete the files with date wise
There is no way to specify a specific date for file deletion with 'rm'.
There are ways to use find to locate files withing a specific date range. You also have to use the 'touch' command to create some empty files with dates around the date you want to find.
For example, if you want to find files from Oct. 1 2010, you would have to create 2 reference files. 1 file with a date of Sep. 30 2010 and one with a date of Oct. 2 2010. The use find.
For example:
# touch -t 201009300101 /tmp/ref1
# touch -t 201010020101 /tmp/ref2
# ll /tmp/ref*
-rw-r--r-- 1 root sys 0 Sep 30 2010 /tmp/ref1
-rw-r--r-- 1 root sys 0 Oct 2 2010 /tmp/ref2
Now to find the files between those dates:
# find /some/dir -newer /tmp/ref1 -a ! -new /tmp/ref2
Here is some test output that I just did:
First I created some files with some Oct 2010 dates with the touch command
# ll
total 32
drwxr-xr-x 2 root sys 8192 Feb 26 10:02 .
drwxr-xr-x 30 root sys 8192 Feb 26 09:44 ..
-rw-r--r-- 1 root sys 0 Oct 1 2010 file1
-rw-r--r-- 1 root sys 0 Oct 1 2010 file2
-rw-r--r-- 1 root sys 0 Oct 1 2010 file3
-rw-r--r-- 1 root sys 0 Oct 3 2010 file4
-rw-r--r-- 1 root sys 0 Oct 4 2010 file5
-rw-r--r-- 1 root sys 0 Oct 5 2010 file6
Now to find files from Oct 1 2010:
# find . -newer /tmp/ref1 -a ! -newer /tmp/ref2 -exec ll +
-rw-r--r-- 1 root sys 0 Oct 1 2010 ./file1
-rw-r--r-- 1 root sys 0 Oct 1 2010 ./file2
-rw-r--r-- 1 root sys 0 Oct 1 2010 ./file3
If you want to delete the files once you are sure they are correct, you can modify your find command:
# find . -newer /tmp/ref1 -a ! -newer /tmp/ref2 -exec rm +
- Tags:
- find