ls -e to find out File modification time in secs


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting ls -e to find out File modification time in secs
# 1  
Old 09-12-2008
ls -e to find out File modification time in secs

Hi All,

I would like to know the file modification time till seconds in Unix. So I tried ls -e and it worked fine. This Solaris 5.10

-rw-rw-r-- 1 test admin 22 Sep 12 11:01:37 2008 test_message

But I am not able to run the same command in SOlaris 5.6 and also in AIX/HP
Is there any other command on those OS and versions.

any help pointer will be of great help.

Regards.
# 2  
Old 09-12-2008
I'm not sure about HPs and older Sun, but I think that your last resort may be to build a perl wrapper around the stat function.
Hope this works, I haven't tested it myself.
# 3  
Old 09-12-2008
try:

Code:
perl -e '$mtime=(stat("filename"))[9]; $cur_time=time();  print $cur_time - $mtime;'

# 4  
Old 09-12-2008
Thanks a lot for ur help. stat function is working perfectly fine

use File::stat;
$sb = stat($filename);
printf "File is %s, size is %s, perm %04o, mtime %s\n",
$filename, $sb->size, $sb->mode & 07777,
scalar localtime $sb->mtime; use File::stat;
$sb = stat($filename);
printf "File is %s, size is %s, perm %04o, mtime %s\n",
$filename, $sb->size, $sb->mode & 07777,
scalar localtime $sb->mtime;

Have not tried the version from dennis. will try.

But can't be get those parameters from Unix shell.
I mean even if not in seconds just the ctime, mtime and atime

Regards,
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX and Linux Applications

Sendmail delay: 3 mins 11 secs... Every time.

Hi all, I would like some help with a sendmail problem: We have a new system comprising of 4 T7-1 servers, each hosting 5 LDOMs, all domains running Solaris 11.3 All emails sent from every one of these domains (including the control domains) sit in the queue for 3 mins 11 secs (sometime 3m 12s,... (11 Replies)
Discussion started by: Mysturji
11 Replies

2. AIX

Getting files through find command and listing file modification time upto seconds

I have to list the files of particular directory using file filter like find -name abc* something and if multiple file exist I also want time of each file up to seconds. Currently we are getting time up to minutes in AIX is there any way I can get file last modification time up to seconds. (4 Replies)
Discussion started by: Nitesh sahu
4 Replies

3. Programming

File date/time modification and permissions

First, oh great Unix gurus, forgive if this is a stupid question. Unix/Linux is not my main thing but I have been programming in C/C++ for many years. I will do my best to be specific. I have a program in C/C++ that needs to modify the time of a given file. Currently I do this using utime()... (5 Replies)
Discussion started by: Pug
5 Replies

4. Shell Programming and Scripting

How to change modification time of file?

Explain it with proper e.g (4 Replies)
Discussion started by: sidpatil
4 Replies

5. Shell Programming and Scripting

How to list the files based on the modification time using the find command?

Hi All, I need to list the files based modification time of the files from a directory, I cannot use "ls -t" as there are lot of files, which "ls" command cannot handle. New files will land there daily. So iam looking for an alternative through "find"command. All suggestions are welcomed. ... (6 Replies)
Discussion started by: Kesavan
6 Replies

6. UNIX for Dummies Questions & Answers

Need Modification Time of a file

Hi all, I need the modification time of a file on a particular day say 3 days before. I just don't want the last modification time. I need all the modification times on a particualar day. Is there anyway to do it? Kindly help. Could anyone tell me where the modification time is stored?... (1 Reply)
Discussion started by: vidhyab
1 Replies

7. Shell Programming and Scripting

Find and symbolic link modification time

Hi, I have a directory made up of many symbolic links to folders multiple file systems. I want to return folders modified within the last 50 days, but find is using the link time rather than the target time. find . -type d -mtime -50 Is there a way to either: a) Make a symbolic link... (1 Reply)
Discussion started by: earls
1 Replies

8. Shell Programming and Scripting

File modification time comparison

Hi All, I have two files (given below) each exists under different paths. I want to compare the modification time stamp of file1.txt is lessthan the modification time of file2.txt. month1=`ls -l file1.txt | awk '{ print $6}'` date1=`ls -file1.txt | awk '{ print $7}'` time1=`ls... (1 Reply)
Discussion started by: Arunprasad
1 Replies

9. UNIX for Dummies Questions & Answers

how to find difference of 2 timestamps in secs?

I have a requirement to find the time difference in second between 2 given time stamps. An example scenario is shown below: 30 Oct 11:42:29:992 DEBUG org.apache.commons.digester.Digester - New match='form-validation/global/validator' (IID=, TID=) 30 Oct 11:42:29:993 DEBUG... (0 Replies)
Discussion started by: Alecs
0 Replies

10. UNIX for Dummies Questions & Answers

File modification time

Does anyone know how to display the time with seconds of when a file was last modified. I can get hour & minutes but would also like seconds. --Running AIX (1 Reply)
Discussion started by: edog
1 Replies
Login or Register to Ask a Question