Find the answer to your Linux question:
Results 1 to 2 of 2
Hi, I need to find the name of the file which get changed latest in a folder. Suppoe I have folder called hostname.within that directory I have two files:file1,file2.Then i ...
  1. #1
    Just Joined!
    Join Date
    Apr 2010
    Posts
    16

    getting last changed filename within a directory

    Hi,
    I need to find the name of the file which get changed latest in a folder.
    Suppoe I have folder called hostname.within that directory I have two files:file1,file2.Then i modified file2.So How can i get the changed file name alone i.e file2.
    I tried ls -lrt | tail -n 2 this will shows all the details(-rwxr-xr-x 1 root root 2588 Jul 14 21:29 file2.txt).I need only that file name alone.can anyone help me to rectify this.

  2. #2
    Linux User
    Join Date
    Jan 2005
    Location
    Saint Paul, MN
    Posts
    262
    Use:
    [code]
    ls -1t | head -n 1
    [code]
    The option for ls are "one" "tee"

Posting Permissions

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