LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   lastest edited file (https://www.linuxquestions.org/questions/linux-newbie-8/lastest-edited-file-938669/)

ofer4 04-07-2012 04:57 PM

lastest edited file
 
hi,

i have alot of files in "logs" directory

and i want to print the name of the lastest updated...

i searched over the internet and i found that i can do with "-nt"....however it didnt work for me...

please, do you have any ideas?

thanks in advance

sycamorex 04-07-2012 05:01 PM

What about:

Code:

ls -1rt |tail -1

ofer4 04-07-2012 05:06 PM

hi thanks it works...

however it prints the lastest updated file in the current folder and i want the lastest updated file in the sub folder "logs".

how can i change your code to execute it?

edit: i solved it thanks you

sycamorex 04-07-2012 05:16 PM

Glad you managed to do it. If you think your problem has been solved you may mark this thread as solved (see thread tools at the top of the page).

David the H. 04-08-2012 10:14 AM

Quote:

it didnt work for me...

This, BTW, is not particularly helpful. How about explaining how it "didn't work"? What were the exact commands you used, and what output did you get, if any? It's important to give relevant details in your question, if you want to increase your chances of getting detailed answers back.


When you have a bit of time, please read How To Ask Questions The Smart Way.


Also, if you figure out the solution yourself after posting, it's polite to post it. That way this thread may be able to help out other people with similar problems who come across it in later searches.


All times are GMT -5. The time now is 05:10 PM.