Find the answer to your Linux question:
Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Getting files modification time

    Dear All,
    Please help me in getting the file name and file modification time of the file in the specified directory.

    I have used the following command.

    1. find $dir/* -prune -printf "%f;%T"

    where, $dir has the directory name.

    Here, the arguments of %f and %T are for printing the file name and file modification time respectively, also ; is a delimiter.

    Here, -printf option in find command is GNU specific one which i can't use.

    Please advice if U know some other ways to get the file name and file modification time. Also, I need to use the command in remote shell, where I may not have the write permission in the remote directory.


  2. #2
    Linux Guru
    Join Date
    Oct 2001
    Täby, Sweden
    Well, the easiest way would probably be to write a C program for it. That does of course introduce a second binary, which might not be desirable.
    If "stat" (the command, not the syscall, which of course is avaiable everywhere) is available on the target machine, you can use that with the appropriate options. It's not as versatile as the -printf option of find, though.
    You could also do "ls -l | awk '{print $8;}'". That's even less versatile, though.
    I'm sure that there are other ways as well, but these were the ones that I could think of off the top of my head. I'd go for the C program approach, if possible.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts