Find the answer to your Linux question:
Results 1 to 2 of 2
I need to write a script that is given a directory as an argument, and it prints the last modified file from that directory and all its subdirectories. for example: ...
  1. #1
    Just Joined!
    Join Date
    May 2010
    Posts
    4

    Find last modified file in current directory and all subdirectories

    I need to write a script that is given a directory as an argument, and it prints the last modified file from that directory and all its subdirectories.

    for example:

    $ newest /usr/etc
    --> /usr/etc/httpd/httpd May 28 12:16

    If I had to do it only for the current dir, it would be easy...
    I'd probably use "ls -lt" and then show only the first line...

    But this "all subdirectories" thingy complicates the things for me.
    How should I do it?
    THANK YOU!

  2. #2
    Just Joined!
    Join Date
    Dec 2007
    Posts
    14
    Add -R to your ls command, that will list the files recursively

Posting Permissions

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