Find the answer to your Linux question:
Results 1 to 5 of 5
How to get the latest created file (only latest created file) from the linux directory using "ls" command. Thanks for any help....
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    May 2005
    Posts
    1

    ls latest created file


    How to get the latest created file (only latest created file) from the linux directory using "ls" command.
    Thanks for any help.

  2. #2
    Linux User
    Join Date
    Jul 2004
    Location
    Poland
    Posts
    368
    Try the following bash pipeline:
    Code:
    ls -ct1 | head -1
    "I don't know what I'm running from
    And I don't know where I'm running to
    There's something deep and strange inside of me I see"

  3. #3
    Linux Enthusiast
    Join Date
    Jan 2005
    Posts
    575
    I don't think Linux stores the date a file was created.It stores the
    date it was last accessed , modified and its i-node was modified.

  4. $spacer_open
    $spacer_close
  5. #4
    Linux User
    Join Date
    Jul 2004
    Location
    Poland
    Posts
    368
    Forgot to mention that.. ctime should be though of as 'change time' rather than 'creation time'. But in many cases it is equal of file creation time, unless you change permisions, owner, etc. Please correct me if I'm wrong.
    "I don't know what I'm running from
    And I don't know where I'm running to
    There's something deep and strange inside of me I see"

  6. #5
    scm
    scm is offline
    Linux Engineer
    Join Date
    Feb 2005
    Posts
    1,044
    Modified time is when the file sectors are changed, ctime is when the inode is changed. Incidentally, you don't need the "1" in the ls to force singlelining output when you're piping the output; it's the default when output isn't to a terminal.

Posting Permissions

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