- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: List with full timestamp of 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
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
тАО06-17-2009 02:53 AM
тАО06-17-2009 02:53 AM
List with full timestamp of files
Using ls -l , we can display the time stamp of file in hours and minutes.
Can we display the full timestamp , with seconds?
Regards
Muktha
- Tags:
- ls.cat
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-17-2009 03:02 AM
тАО06-17-2009 03:02 AM
Re: List with full timestamp of files
>>Can we display the full timestamp , with seconds?
I think it's not possable to see time stamp with second.
Suraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-17-2009 03:03 AM
тАО06-17-2009 03:03 AM
Re: List with full timestamp of files
ls --time-style=+%Y%m%d-%H%M%S -l
According to the manpage it's in standard `date` formating.
Best regards
Fredrik Eriksson
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-17-2009 03:04 AM
тАО06-17-2009 03:04 AM
Re: List with full timestamp of files
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-17-2009 03:35 AM
тАО06-17-2009 03:35 AM
Re: List with full timestamp of files
I thought its not possible to get timestamp with second field. After digging the forum I got a Perl script on this thread see the below link
http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=1123761&admit=109447626+1245238228339+28353475
Here is the Perl script to listing with second.
perl -e 'foreach(@ARGV){$time=localtime((stat($_))[9]);printf("%-30s%s\n",$_,$time)}' *
Suraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-17-2009 03:56 AM
тАО06-17-2009 03:56 AM
Re: List with full timestamp of files
If you use Perl's POSIX module you can format the timestamp in any way you like. The formatting directives for 'strftime()' are the same you know from the shell's 'date' caommand. For example:
# perl -MPOSIX -le 'for (@ARGV) {-e $_ && print join " ",strftime("%b %2d %Y %X",localtime((lstat($_))[9])),$_}' /home/muktha/*
This variation silently ignores non-existent files and directories and shows the mtime of a symbolic link rather than the object of that link. To see the contents of a directory (at one level), specify the argument(s) with the trailing "/*" as my example shows.
Regards!
...JRF...
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-17-2009 04:36 AM
тАО06-17-2009 04:36 AM
Re: List with full timestamp of files
Many thanks to all.
Perl command works fine.
As I am not good in Perl, can u please explain me that command?
--timestyle option is not working in my Unix box.
I had one more request , can we list in ascending or descending order
Regards
Muktha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-17-2009 04:47 AM
тАО06-17-2009 04:47 AM
Re: List with full timestamp of files
ls --time-style=+%Y%m%d-%H%M%S -l
According to the manpage it's in standard `date` formating."
only according to the *Linux* man page. not the "unix" man page. the giveaway is the "double-minus" in the option.
if you really want that option, you can install gnu coreutils
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-17-2009 04:58 AM
тАО06-17-2009 04:58 AM
Re: List with full timestamp of files
# perl -MPOSIX -le 'for (@ARGV) {-e $_ && print join " ",strftime("%b %2d %Y %X",localtime((lstat($_))[9])),$_}' /home/muktha/*
This uses the POSIX module to offer 'strftime()' formating as I noted. The script examines every argument passed (as held in @ARGV). For each element which exists (-e) a stat() system call is made to obtain the modification timestamp (field-9 of the stat() structure). Since this timestamp is in Epoch seconds, we convert it to your localtime zone's interpretation, format its elements with strftime() and print the formatted string together with the element we just extracted from the argument list (@ARGV).
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-17-2009 05:16 PM
тАО06-17-2009 05:16 PM
Re: List with full timestamp of files
> I had one more request , can we list in ascending or descending order?
OK, I missed that. One very simple way to accomodate that is this variation (which adds the Epoch timestamp in the first column. Now you can pipe the output to a sort and order the results in descending or ascending order:
# perl -MPOSIX -le 'for (@ARGV) {-e $_ && ($t=(lstat($_))[9]) && print join " ",$t,strftime("%b %2d %Y %X",localtime($t)),$_}' ./* |sort -krn1,1
...which would present the contents of the current directory's files (./*) in descending age order.
Regards!
...JRF...