System log files are serialized and I use ls -lrt to show me the most recent file. I then cat that file. This requires typing a long serial number each time. How can I cat the last file appearing in my ls -lrt output in one command?I'm using cygwin and the the output from ls -lrt foobar_job* look like this:--rw-r--r-- 1 zundarz Domain Users   1133 Jul 31 16:54 foobar_job4855125.log-rw-r--r-- 1 zundarz Domain Users   1256 Jul 31 17:10 foobar_job4855127.log-rw-r--r-- 1 zundarz Domain Users   1389 Aug 11 10:20 foobar_job4887829.log-rw-r--r-- 1 zundarz Domain Users   1228 Aug 11 10:39 foobar_job4887834.log
Single line command to cat last file in ls -lrt output?
ls;cat
If you're going to just cat a newest file in one command you don't really need -l option. On Linux and Cygwin you can use -1 option and make parsing much easier:$ cat $(ls -1rt | tail -n1)-1 should be very portable, it's specified in POSIX.Also keep in mind that parsing ls output has its drawbacks.EDIT:As correctly noted in a comment by don_crissti you don't even need -1: $ cat $(ls -rt | tail -n1)