- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- how to get count of files created on specific date...
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
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
тАО09-13-2017 11:28 PM
тАО09-13-2017 11:28 PM
Hi Experts,
I have lots of file in 1 directory and want the count of files created on specific date. i.e. I am getting count of files created on septermber 13, 2017 with below command :
ls -l | grep "Sep 13" | wc -l
but this command provides the count of all the files created on Septemeber 13 of all the year instead of year 2017.
Please help me to get the count of files created on specific date and year.
Solved! Go to Solution.
- Tags:
- find
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-14-2017 11:05 PM
тАО09-14-2017 11:05 PM
Re: how to get count of files created on specific date (yesterday)
> I have lots of file in 1 directory [...]
On what?
uname -a
> ls -l | [...]
Parsing "ls -l" output is almost always more work than it's worth.
The usual way to do things like this is with "find", particularly using
"[!] -newer" to set the date-time limits. Use "touch -t" to
create/modify a comparison file (or two) for use with "-newer". (Having
to create a file to specify a date-time value is lame, but easy enough
to do.)
A Forum or Web search for keywords like:
find -newer touch
should find many examples.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-14-2017 11:29 PM - edited тАО09-14-2017 11:31 PM
тАО09-14-2017 11:29 PM - edited тАО09-14-2017 11:31 PM
Re: how to get count of files created on specific date (yesterday)
The creation timestamp is the same as the modification timestamp. In other words, you can only see when the file was last created or modified.
The ll command changes the format of the timestamp when the timestamp is older than 6 months (the hour:minute changes to the year (YYYY). So it is a very poor tool for selecting or sorting by timestamp.
The tool to use is find which has Boolean expression capabilities. The technique to find files within a time range is the -newer primary. Then provide two temporary files, one with a timestamp at the beginning of the range and the other at the end. Then use find to list all files within that range.
For the Sep 13, 2017 range, create two files like this:
cd /desired-directory touch -t 201709130000.00 start-time touch -t 201709132359.59 end-time
The filenames can be anything and can be removed after the find is complete.
The -t option is YYYYmmddhhmm.ss
Now use this command to display all files within the time range:
cd /desired-directory find . -type f -newer start-time ! -newer end-time -exec ls -lt {} \;
To show just the filenames, leave off everything from -exec to the end:
cd /desired-directory find . -type f -newer start-time ! -newer end-time
The above is a simple example.
To be completely accurate and find files created exactly at the beginning of Sep 13, the start-time should be changed to the last second of the previous day:
touch -t 201709122359.59 start-time
Now a file created or modified on Sep 9 at 00:00.00 will be included.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-15-2017 02:21 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-16-2017 11:14 PM
тАО09-16-2017 11:14 PM
Re: how to get count of files created on specific date (yesterday)
> ll(1) changes the format of the timestamp when the timestamp is older than 6 months
You can change the message catalog so that the two formats are identical. :-)