GZip most recent file
I know that the best way to find the most recent file is through an operation like:
ls -l -rt | tail -1
But I'm wanting to gzip this (most recent) file, because the 开发者_运维知识库program I'm writing will be putting a file in the current directory via a constructed command line argument in an outside interface. The user of the program shouldn't be aware of any background processes.
Thanks!
Try with another pipe :
cat `ls -rt | tail -1` | gzip > file.gz
精彩评论