Find the answer to your Linux question:
Results 1 to 8 of 8
Hi, I want to know the last modified time (TimeStamp) of a file so that can compare it with some TimeStamp and delete it. Help is appreciated. Thanks...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Aug 2005
    Location
    India
    Posts
    7

    To get last modified time of a file


    Hi,

    I want to know the last modified time (TimeStamp) of a file so that can compare it with some TimeStamp and delete it.

    Help is appreciated.
    Thanks

  2. #2
    Linux User
    Join Date
    Aug 2005
    Location
    Italy
    Posts
    401

    stat

    You can use stat... I suggest a "man stat"
    When using Windows, have you ever told "Ehi... do your business?"
    Linux user #396597 (http://counter.li.org)

  3. #3
    Just Joined!
    Join Date
    Aug 2005
    Location
    India
    Posts
    7
    Though this is a Linux forum but I am working on AIX and it don't support stat command. Any other alternate?

  4. #4
    Linux Newbie
    Join Date
    Oct 2004
    Posts
    158
    Code:
    ll  <filename>
    shows the last time the file was modified.

  5. #5
    Linux Engineer
    Join Date
    Mar 2005
    Posts
    1,431
    "ll" isn't an preconfigured alias in all distros, if it doesn't work try "ls -l file"

  6. #6
    Linux Newbie
    Join Date
    Oct 2004
    Posts
    158
    It used to work just fine on AIX.... the platform he's on.
    And you're right, it isn't available everywhere.

  7. #7
    scm
    scm is offline
    Linux Engineer
    Join Date
    Feb 2005
    Posts
    1,044
    ll is just an alias, best to use the real command. It's always annoyed me that there's not easy way to get the times of files (GNU's stat() notwithstanding) and I've usually resorted to writing my own for those systems that don't provide it.
    Code:
    MTIME=$&#40;/bin/ls -lo file | /usr/bin/awk '&#123;print $5,$6,$7&#125;'&#41;
    will get you the raw information, but be aware that $7 may be the time or the year, depending on the whether the file was modified within the last year.

  8. #8
    Just Joined!
    Join Date
    Aug 2005
    Location
    India
    Posts
    7
    Thanks to all who replied to my query.
    Actually I want to check the files in a directory for certain TimeStamp for modification and want to send the names of those files in the mail.
    I am a java developer and not an expert in writing scripts. So help is appreciated.

    Regards.

Posting Permissions

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