简体   繁体   中英

Tar files that were modified in the last 2 days

I am trying to tar all the files in my downloads folder that was changed in the last 2 days. When I execute the below, it instead tar's all the files inside my Downloads folder

find ~/Downloads -mtime 2 -print0 | xargs -0 tar -cvfz test.tar.gz 

尝试使用 -mtime -2,在两天内压缩所有文件。

确保使用find ~/Downloads/*而不是find ~/Downloads因为find ~/Downloads还将返回父文件夹~/Downloads这导致整个文件夹被存档,而不仅仅是更改的文件。

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