Unix/Linux Go Back    

Shell Programming and Scripting BSD, Linux, and UNIX shell scripting Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

Is there any way to show timestamp instead of date in "ls l"

Shell Programming and Scripting

Thread Tools Search this Thread Display Modes
Old Unix and Linux 02-19-2006
umen umen is offline
Registered User
Join Date: Aug 2005
Last Activity: 8 August 2017, 2:58 AM EDT
Posts: 277
Thanks: 0
Thanked 2 Times in 2 Posts
Is there any way to show timestamp instead of date in "ls l"

is there any way build in by unix native commands to show timestamp instead of date when I do "ls l" ?
if not is there any one liner script to do this?
Sponsored Links
Old Unix and Linux 02-19-2006
blowtorch's Unix or Linux Image
blowtorch blowtorch is offline Forum Advisor  
Join Date: Dec 2004
Last Activity: 1 July 2016, 6:18 AM EDT
Location: UK
Posts: 2,351
Thanks: 0
Thanked 6 Times in 6 Posts
Do you want to show the time a file was modified instead of the date? Excerpt from the man page of ls
If the time of last modification is greater than six months ago, it is shown in the format `month date year' for the POSIX locale. When the LC_TIME locale category is not set to the POSIX locale, a different format of the time field may be used. Files modified within six months show `month date time'.
As for a simple one liner, I can give you a simple two liner:

#!/usr/bin/perl -w #-d
$mtime=(stat($ARGV[0]))[9]; @ltime=localtime $mtime; printf "%.4d-%.2d-%.2d-%.2d-%.2d\n",$ltime[5]+1900,$ltime[4]+1,$ltime[3],$ltime[2],$ltime[1];

Sponsored Links

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
awk command to replace ";" with "|" and ""|" at diferent places in line of file shis100 Shell Programming and Scripting 7 03-16-2011 08:59 AM
show dots when script is "thinking" pkohn11 Shell Programming and Scripting 10 05-07-2010 04:51 PM
HowTo: reg expr doing grep "timestamp>$DesiredTime" logfile ? Browser_ice Shell Programming and Scripting 5 07-05-2009 02:17 PM
add seconds to: date"|"time"|"HHMMSS anaconga UNIX for Advanced & Expert Users 3 08-27-2008 01:17 PM

All times are GMT -4. The time now is 09:47 AM.