简体   繁体   中英

display the most recent file in a directory using linux shell

I need to display the content of the recent file in a directory, for my example it's a log file that gets generated for each execution hence I need to display the newest one the command :

ls -Art | tail -n 1 

output the right name, meaning the most recent file in a directory, my goal is to output the content of this file by further piping How could we do this?

cat `ls -Art | tail -n1`

或者,

ls -Art | tail -n 1 | xargs cat

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM