How to get access time of a file upto the precision of seconds?


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users How to get access time of a file upto the precision of seconds?
# 8  
Old 04-01-2011
I dont understand what works here..This is the output when I ran the above command..What do I do ?????

ls -ltu --time-style=+%H:%M:%S abc
ls: illegal option -- -
ls: illegal option -- e
ls: illegal option -- -
ls: illegal option -- y
ls: illegal option -- e
ls: illegal option -- =
ls: illegal option -- +
ls: illegal option -- %
ls: illegal option -- H
ls: illegal option -- :
ls: illegal option -- %
ls: illegal option -- M
ls: illegal option -- :
ls: illegal option -- %
ls: illegal option -- S
usage: ls -1RaAdCxmnlhogrtucpFbqisfL@ [files]

---------- Post updated at 01:34 AM ---------- Previous update was at 01:32 AM ----------

@methyl :

Code:
uname -a
SunOS ohclexor4022 5.9 Generic_122300-08 sun4u sparc SUNW,Sun-Fire-880

I dont have the root level access.
I have never worked on perl before.Can I use it in my shell script.
??
Please help....... Smilie Smilie

Last edited by Yogesh Sawant; 04-09-2011 at 07:49 AM.. Reason: added code tags
# 9  
Old 04-01-2011
See the last post in this thread for my perl solution.
This User Gave Thanks to Perderabo For This Post:
# 10  
Old 04-01-2011
Hi Kanus,

I don't have access to SunOS System, but I found man page of ls in the web. I see in SunOS doesn't have --time-style option. For that reason you receive that errors.

Reading the options you have, instead of:

Code:
ls -ltu --time-style=+%H:%M:%S yourfile

try with the following 2 command and see the difference:
Code:
ls -ltu yourfile

and
Code:
ls -etu yourfile # I guess this could be near of what you want

Code:
Reference: man ls in SunOS 5.10
     -e           The same as -l, except  displays  time  to  the
                  second,  and  with  one  format  for  all files
                  regardless of age: mmm dd hh:mm:ss yyyy.

     -E           The same as -l, except  displays  time  to  the
                  nanosecond  and  with  one format for all files
                  regardless       of       age:       yyyy-mm-dd
                  hh:mm:ss.nnnnnnnnn (ISO 8601:2000 format).

                  In addition, this option  displays  the  offset
     -l           Lists in long format, giving mode, ACL  indica-
                  tion,  number  of  links, owner, group, size in
                  bytes, and time of last modification  for  each
                  file  (see  above).  If  the  file is a special
                  file, the size field instead contains the major
                  and  minor  device numbers. 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 dif-
                  ferent format of the time field  can  be  used.
                  Files  modified  within  six months show `month
                  date time'. If the file is a symbolic link, the
                  filename  is  printed  followed by "->" and the
                  path name of the referenced file.

     -t           Sorts by time stamp (latest first)  instead  of
                  by  name.  The default is the last modification
                  time. (See -u and -c.)

     -u           Uses time of last access instead of last modif-
                  ication  for  sorting  (with  the -t option) or
                  printing (with the -l option).

Hope it helps.

Regards.
This User Gave Thanks to cgkmal For This Post:
# 11  
Old 04-01-2011
pleaseeeee help...m tired :(

Thanks for helping me guys..
I really appreciate it..But what do I do..nothing works here..
this is what I got..as output..

ls -ltu --time-style=+%H:%M:%S abc
ls: illegal option -- -
ls: illegal option -- e
ls: illegal option -- -
ls: illegal option -- y
ls: illegal option -- e
ls: illegal option -- =
ls: illegal option -- +
ls: illegal option -- %
ls: illegal option -- H
ls: illegal option -- :
ls: illegal option -- %
ls: illegal option -- M
ls: illegal option -- :
ls: illegal option -- %
ls: illegal option -- S
usage: ls -1RaAdCxmnlhogrtucpFbqisfL@ [files]

m using the following version :

uname -a

SunOS ohclexor4022 5.9 Generic_122300-08 sun4u sparc SUNW,Sun-Fire-880

Smilie Smilie

---------- Post updated at 02:58 AM ---------- Previous update was at 02:51 AM ----------

ls -etu abc
ls: illegal option -- e
usage: ls -1RaAdCxmnlhogrtucpFbqisfL@ [files]

Smilie

---------- Post updated at 02:59 AM ---------- Previous update was at 02:58 AM ----------

The man page u attaches is og 5.10 mine is 5.9///
thats y.. Smilie

---------- Post updated at 04:54 AM ---------- Previous update was at 02:59 AM ----------

Thanx a milllion Perderabo..
Ur perl command is working...M sooooooo happy..Thanks every1 for your time and help !!!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. 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

2. UNIX for Dummies Questions & Answers

Delay of upto 7 seconds after typing in putty

Hi Friends, I am facing a very strange issue . I type something on putty session of servers of my work(locating in North America) and it appears only after 7 seconds or so. I am located in India. It doesn't happen with my colleagues who are sitting next to me :(. I use the ssh protocol to connect... (4 Replies)
Discussion started by: kunwar
4 Replies

3. UNIX and Linux Applications

Limit Website access upto specific count

Hi to all, I am new to Linux. but i am facing issue with my web server in Ubuntu 11.10. In my webserver i want to restrict maximum users website access (e.g., suppose i want to restrict users to access web to 250 persons in single time). So can you please suggest me to how to do that in... (1 Reply)
Discussion started by: Chintanghanti
1 Replies

4. UNIX for Advanced & Expert Users

Print particular time upto the next occurance

Hi Guys, I am having some issue in one aspect. I am having data like - 00:00 X-1 Y-1 Z-4 A-5 E-6 . . . . 01:00 Z-9 X-1 Z-5 A-8 E-7 (2 Replies)
Discussion started by: aniketdixit
2 Replies

5. Programming

How to search a file based on a time stamp backwards 10 seconds

Hi all, I'm after some help with this small issue which i'm struggling to work out a fix for. I have a file that contains records that all have a time stamp for each individual record, i need to search the file for a specific time stamp and then search back 10 seconds to see if the number... (2 Replies)
Discussion started by: sp3arsy
2 Replies

6. Shell Programming and Scripting

need the last access time for a .gz file

i have file named aaaa. The file aaaa was zipped on one particular time. Need to know the command to find out when the file "aaaa" was actually zipped. (1 Reply)
Discussion started by: expert
1 Replies

7. Shell Programming and Scripting

Time difference in seconds

date1=$(date +"%H:%M:%S") date2=$(date +"01:00:54") diff=$date2-$date1 echo $diff How to get the time difference in seconds. (4 Replies)
Discussion started by: sandy1028
4 Replies

8. Shell Programming and Scripting

File creation time in seconds

Hi All, Cany any one help me in solving this.. Problem statement: I have a requirement to find the time from which there are no files created in a given directory. For this I am assuming that I need to get the file creation time in seconds, then the current time in seconds using `date +%s`.... (7 Replies)
Discussion started by: chary
7 Replies

9. UNIX for Dummies Questions & Answers

Access time of a file

I thought that access time of a file is time when the file was run last time (or I read somewhere that it's time when system lookup the file -> but I'm not sure when it really is) How is it exactly? Thank you for help! (11 Replies)
Discussion started by: MartyIX
11 Replies

10. Programming

find CPU Time for a function (subsecond precision)

Hi, I need to time a certain function in my C/C++ code and I am experiencing some difficulties. I timed it using wallclock time so I know that it takes approximately 500-600 microseconds with gettimeofday(&start, NULL); // my function call gettimeofday(&end, NULL); answer = (end.tv_sec -... (2 Replies)
Discussion started by: zynnel
2 Replies
Login or Register to Ask a Question