|
google site
|
|||||||
| Forums | Register | Blog | Man Pages | Forum Rules | Links | Albums | FAQ | Users | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
![]() |
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
How to get the latest modified file name in /home directory?
I only know how to list all sub-directories or files in specified directory. I don't know how to order them by modified date, furthermore, I don't know how to get the top one file in the sorted list. Wish you can do me a favor. Thanks in advance!
|
| Sponsored Links | ||
|
|
|
#2
|
||||
|
||||
|
In ls there in a option called -t .It will list based on the modified time . Code:
ls -lrt To get the recently modified file use the following, Code:
ls -lrt | tail -n 2 |
|
#3
|
||||
|
||||
|
Check the man pages of ls and head.
ls -lrt ls -lrt | head -1 |
|
#4
|
|||
|
|||
|
Thank you both! My problem is solved with your solutions.
|
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how to open a last modified file in a directory | apsprabhu | UNIX for Advanced & Expert Users | 5 | 02-24-2010 12:20 AM |
| How to find the latest modified file from the unix server. | sreenu80 | Shell Programming and Scripting | 2 | 10-16-2009 05:40 AM |
| Copy the latest file to a directory | spkandy | Shell Programming and Scripting | 2 | 08-10-2009 04:16 AM |
| Copy the latest file from one directory to another | chandancsc | Shell Programming and Scripting | 3 | 08-07-2009 04:35 AM |
| How to zip a modified file 15 days before but not scanning my sub directory files | skrish70 | Shell Programming and Scripting | 1 | 10-10-2005 03:41 PM |