我想将一月份的文件压缩成 tar gz

我想将一月份的文件压缩成 tar gz
-rw-r--r--. 1 root root   4788074 Jan  1 01:50 2020-01-01-00-50-18.done.csv
-rw-r--r--. 1 root root   4842864 Jan  1 02:50 2020-01-01-01-50-18.done.csv
-rw-r--r--. 1 root root   4923486 Jan  1 03:50 2020-01-01-02-50-18.done.csv
-rw-r--r--. 1 root root   4680510 Jan  1 04:50 2020-01-01-03-50-18.done.csv
-rw-r--r--. 1 root root   4677980 Jan  1 05:50 2020-01-01-04-50-18.done.csv
-rw-r--r--. 1 root root   4751777 Jan  1 06:50 2020-01-01-05-50-18.done.csv
-rw-r--r--. 1 root root   4548556 Jan  1 07:50 2020-01-01-06-50-18.done.csv
-rw-r--r--. 1 root root   4722964 Jan  1 08:50 2020-01-01-07-50-18.done.csv
-rw-r--r--. 1 root root   4559160 Jan  1 09:50 2020-01-01-08-50-18.done.csv
-rw-r--r--. 1 root root   4874675 Jan  1 10:50 2020-01-01-09-50-18.done.csv
-rw-r--r--. 1 root root   4824802 Jan  1 11:50 2020-01-01-10-50-18.done.csv
-rw-r--r--. 1 root root   4865174 Jan  1 12:50 2020-01-01-11-50-18.done.csv
-rw-r--r--. 1 root root   4968536 Jan  1 13:50 2020-01-01-12-50-18.done.csv
-rw-r--r--. 1 root root   4732558 Jan  1 14:50 2020-01-01-13-50-18.done.csv
-rw-r--r--. 1 root root   4529904 Jan  1 15:50 2020-01-01-14-50-18.done.csv
-rw-r--r--. 1 root root   4635235 Jan  1 16:50 2020-01-01-15-50-18.done.csv
-rw-r--r--. 1 root root   4642695 Jan  1 17:50 2020-01-01-16-50-18.done.csv
-rw-r--r--. 1 root root   4692022 Jan  1 18:50 2020-01-01-17-50-18.done.csv
-rw-r--r--. 1 root root   4576366 Jan  1 19:50 2020-01-01-18-50-18.done.csv
-rw-r--r--. 1 root root   4656134 Jan  1 20:50 2020-01-01-19-50-18.done.csv
-rw-r--r--. 1 root root   4488401 Jan  1 21:50 2020-01-01-20-50-18.done.csv
-rw-r--r--. 1 root root   4951205 Jan  1 22:50 2020-01-01-21-50-18.done.csv
-rw-r--r--. 1 root root   4811404 Jan  1 23:50 2020-01-01-22-50-18.done.csv
-rw-r--r--. 1 root root   4844354 Jan  2 00:50 2020-01-01-23-50-18.done.csv
-rw-r--r--. 1 root root   4537539 Jan  2 01:50 2020-01-02-00-50-18.done.csv
-rw-r--r--. 1 root root   4759361 Jan  2 02:50 2020-01-02-01-50-18.done.csv
-rw-r--r--. 1 root root   4668596 Jan  2 03:50 2020-01-02-02-50-18.done.csv
-rw-r--r--. 1 root root   4673695 Jan  2 04:50 2020-01-02-03-50-18.done.csv
-rw-r--r--. 1 root root   4723943 Jan  2 05:50 2020-01-02-04-50-18.done.csv
-rw-r--r--. 1 root root   4990460 Jan  2 06:50 2020-01-02-05-50-18.done.csv
-rw-r--r--. 1 root root   4652880 Jan  2 07:50 2020-01-02-06-50-18.done.csv
-rw-r--r--. 1 root root   4741079 Jan  2 08:50 2020-01-02-07-50-18.done.csv
-rw-r--r--. 1 root root   4657027 Jan  2 09:50 2020-01-02-08-50-18.done.csv
-rw-r--r--. 1 root root   4946855 Jan  2 10:50 2020-01-02-09-50-18.done.csv
-rw-r--r--. 1 root root   4803728 Jan  2 11:50 2020-01-02-10-50-18.done.csv
-rw-r--r--. 1 root root   5017282 Jan  2 12:50 2020-01-02-11-50-18.done.csv
-rw-r--r--. 1 root root   4911913 Jan  2 13:50 2020-01-02-12-50-18.done.csv
-rw-r--r--. 1 root root   4816238 Jan  2 14:50 2020-01-02-13-50-18.done.csv
-rw-r--r--. 1 root root   5313896 Jan  2 15:50 2020-01-02-14-50-18.done.csv
-rw-r--r--. 1 root root   4575515 Jan  2 16:50 2020-01-02-15-50-18.done.csv
-rw-r--r--. 1 root root   5007872 Jan  2 17:50 2020-01-02-16-50-18.done.csv
-rw-r--r--. 1 root root   4584649 Jan  2 18:50 2020-01-02-17-50-18.done.csv
-rw-r--r--. 1 root root   4741846 Jan  2 19:50 2020-01-02-18-50-18.done.csv
-rw-r--r--. 1 root root   4555937 Jan  2 20:50 2020-01-02-19-50-18.done.csv
-rw-r--r--. 1 root root   4673201 Jan  2 21:50 2020-01-02-20-50-18.done.csv
-rw-r--r--. 1 root root   4577218 Jan  2 22:50 2020-01-02-21-50-18.done.csv
-rw-r--r--. 1 root root   5155948 Jan  2 23:50 2020-01-02-22-50-18.done.csv
-rw-r--r--. 1 root root   4687444 Jan  3 00:50 2020-01-02-23-50-18.done.csv
-rw-r--r--. 1 root root   4792506 Jan  3 01:50 2020-01-03-00-50-18.done.csv
-rw-r--r--. 1 root root   4843106 Jan  3 02:50 2020-01-03-01-50-18.done.csv
-rw-r--r--. 1 root root   4934162 Jan  3 03:50 2020-01-03-02-50-18.done.csv
-rw-r--r--. 1 root root   4716092 Jan  3 04:50 2020-01-03-03-50-18.done.csv
-rw-r--r--. 1 root root   4905969 Jan  3 05:50 2020-01-03-04-50-18.done.csv
-rw-r--r--. 1 root root   4690858 Jan  3 06:50 2020-01-03-05-50-18.done.csv
-rw-r--r--. 1 root root   4828489 Jan  3 07:50 2020-01-03-06-50-18.done.csv
-rw-r--r--. 1 root root   4821478 Jan  3 08:50 2020-01-03-07-50-18.done.csv
-rw-r--r--. 1 root root   4894036 Jan  3 09:50 2020-01-03-08-50-18.done.csv
-rw-r--r--. 1 root root   5424323 Jan  3 10:50 2020-01-03-09-50-18.done.csv
-rw-r--r--. 1 root root   4744014 Jan  3 11:50 2020-01-03-10-50-18.done.csv
-rw-r--r--. 1 root root   4932617 Jan  3 12:50 2020-01-03-11-50-18.done.csv
-rw-r--r--. 1 root root   4842501 Jan  3 13:50 2020-01-03-12-50-18.done.csv
-rw-r--r--. 1 root root   4524026 Jan  3 14:50 2020-01-03-13-50-18.done.csv
-rw-r--r--. 1 root root   4946224 Jan  3 15:50 2020-01-03-14-50-18.done.csv
-rw-r--r--. 1 root root   4566169 Jan  3 16:50 2020-01-03-15-50-18.done.csv
-rw-r--r--. 1 root root   4773635 Jan  3 17:50 2020-01-03-16-50-18.done.csv
-rw-r--r--. 1 root root   4798284 Jan  3 18:50 2020-01-03-17-50-18.done.csv
-rw-r--r--. 1 root root   5288375 Jan  3 19:50 2020-01-03-18-50-18.done.csv
-rw-r--r--. 1 root root   4898281 Jan  3 20:50 2020-01-03-19-50-18.done.csv
-rw-r--r--. 1 root root   4506452 Jan  3 21:50 2020-01-03-20-50-18.done.csv
-rw-r--r--. 1 root root   4646175 Jan  3 22:50 2020-01-03-21-50-18.done.csv
-rw-r--r--. 1 root root   5030097 Jan  3 23:50 2020-01-03-22-50-18.done.csv
-rw-r--r--. 1 root root   5605197 Jan  4 00:50 2020-01-03-23-50-18.done.csv
-rw-r--r--. 1 root root   4736382 Jan  4 01:50 2020-01-04-00-50-18.done.csv
-rw-r--r--. 1 root root   4592270 Jan  4 02:50 2020-01-04-01-50-18.done.csv
-rw-r--r--. 1 root root   4813510 Jan  4 03:50 2020-01-04-02-50-18.done.csv
-rw-r--r--. 1 root root   4567148 Jan  4 04:50 2020-01-04-03-50-18.done.csv
-rw-r--r--. 1 root root   4741853 Jan  4 05:50 2020-01-04-04-50-18.done.csv
-rw-r--r--. 1 root root   4751927 Jan  4 06:50 2020-01-04-05-50-18.done.csv
-rw-r--r--. 1 root root   5506448 Jan  4 07:50 2020-01-04-06-50-18.done.csv
-rw-r--r--. 1 root root   4530657 Jan  4 08:50 2020-01-04-07-50-18.done.csv
-rw-r--r--. 1 root root   4719368 Jan  4 09:50 2020-01-04-08-50-18.done.csv
-rw-r--r--. 1 root root   4496496 Jan  4 10:50 2020-01-04-09-50-18.done.csv
-rw-r--r--. 1 root root   5381188 Jan  4 11:50 2020-01-04-10-50-18.done.csv
-rw-r--r--. 1 root root   4748541 Jan  4 12:50 2020-01-04-11-50-18.done.csv
-rw-r--r--. 1 root root   4851498 Jan  4 13:50 2020-01-04-12-50-18.done.csv
-rw-r--r--. 1 root root   4617132 Jan  4 14:50 2020-01-04-13-50-18.done.csv
-rw-r--r--. 1 root root   4681207 Jan  4 15:50 2020-01-04-14-50-18.done.csv
-rw-r--r--. 1 root root   4494570 Jan  4 16:50 2020-01-04-15-50-18.done.csv
-rw-r--r--. 1 root root   4615356 Jan  4 17:50 2020-01-04-16-50-18.done.csv
-rw-r--r--. 1 root root   4547251 Jan  4 18:50 2020-01-04-17-50-18.done.csv
-rw-r--r--. 1 root root   4805116 Jan  4 19:50 2020-01-04-18-50-18.done.csv
-rw-r--r--. 1 root root   4459534 Jan  4 20:50 2020-01-04-19-50-18.done.csv
-rw-r--r--. 1 root root   4604982 Jan  4 21:50 2020-01-04-20-50-18.done.csv
-rw-r--r--. 1 root root   4541867 Jan  4 22:50 2020-01-04-21-50-18.done.csv
-rw-r--r--. 1 root root   4634665 Jan  4 23:50 2020-01-04-22-50-18.done.csv
-rw-r--r--. 1 root root   6385276 Jan  5 00:50 2020-01-04-23-50-18.done.csv
-rw-r--r--. 1 root root   4720039 Jan  5 01:50 2020-01-05-00-50-18.done.csv
-rw-r--r--. 1 root root   4538038 Jan  5 02:50 2020-01-05-01-50-18.done.csv
-rw-r--r--. 1 root root   4805062 Jan  5 03:50 2020-01-05-02-50-18.done.csv
-rw-r--r--. 1 root root   4504024 Jan  5 04:50 2020-01-05-03-50-18.done.csv
-rw-r--r--. 1 root root   4741266 Jan  5 05:50 2020-01-05-04-50-18.done.csv
-rw-r--r--. 1 root root   4523127 Jan  5 06:50 2020-01-05-05-50-18.done.csv
-rw-r--r--. 1 root root   4618309 Jan  5 07:50 2020-01-05-06-50-18.done.csv
-rw-r--r--. 1 root root   4482153 Jan  5 08:50 2020-01-05-07-50-18.done.csv
-rw-r--r--. 1 root root   4622415 Jan  5 09:50 2020-01-05-08-50-18.done.csv
-rw-r--r--. 1 root root   4649883 Jan  5 10:50 2020-01-05-09-50-18.done.csv
-rw-r--r--. 1 root root   4861573 Jan  5 11:50 2020-01-05-10-50-18.done.csv
-rw-r--r--. 1 root root   4732140 Jan  5 12:50 2020-01-05-11-50-18.done.csv
-rw-r--r--. 1 root root   5198848 Jan  5 13:50 2020-01-05-12-50-18.done.csv
-rw-r--r--. 1 root root   4480850 Jan  5 14:50 2020-01-05-13-50-18.done.csv
-rw-r--r--. 1 root root   4508642 Jan  5 15:50 2020-01-05-14-50-18.done.csv
-rw-r--r--. 1 root root   4518709 Jan  5 16:50 2020-01-05-15-50-18.done.csv
-rw-r--r--. 1 root root   4575821 Jan  5 17:50 2020-01-05-16-50-18.done.csv
-rw-r--r--. 1 root root   4507744 Jan  5 18:50 2020-01-05-17-50-18.done.csv
-rw-r--r--. 1 root root   4643905 Jan  5 19:50 2020-01-05-18-50-18.done.csv
-rw-r--r--. 1 root root   4473434 Jan  5 20:50 2020-01-05-19-50-18.done.csv
-rw-r--r--. 1 root root   4543923 Jan  5 21:50 2020-01-05-20-50-18.done.csv
-rw-r--r--. 1 root root   4487512 Jan  5 22:50 2020-01-05-21-50-18.done.csv
-rw-r--r--. 1 root root   4759356 Jan  5 23:50 2020-01-05-22-50-18.done.csv
-rw-r--r--. 1 root root   4637896 Jan  6 00:50 2020-01-05-23-50-18.done.csv
-rw-r--r--. 1 root root   7364516 Jan  6 01:50 2020-01-06-00-50-18.done.csv
-rw-r--r--. 1 root root   6389317 Jan  6 02:50 2020-01-06-01-50-18.done.csv
-rw-r--r--. 1 root root   6655708 Jan  6 03:50 2020-01-06-02-50-18.done.csv
-rw-r--r--. 1 root root   6398235 Jan  6 04:50 2020-01-06-03-50-18.done.csv
-rw-r--r--. 1 root root   6452437 Jan  6 05:50 2020-01-06-04-50-18.done.csv

我想将 1 月份的文件压缩成 tar gz

答案1

要使用文件名(而不是文件时间戳)存档整个一月份,您可以使用:

tar czvf 2020-01.tar.gz 2020-01*.csv

如果您想要分别存档一月的上半月和下半月,并且您使用的 shell 支持括号扩展(例如 bash):

tar czvf 2020-01-A.tar.gz 2020-01-{01..15}*.csv
tar czvf 2020-01-B.tar.gz 2020-01-{16..31}*.csv

如果某些日期缺少文件,您可能会收到错误,但仍会创建档案。

相关内容