我如何获得结果将在开始的文件总数 #count 中有文件名。当我在下面运行命令行时只显示文件数而不显示文件名。
我想要 zip 文件名并计算 zip 中的文档数。谢谢
输出:
IAD1.zip 30000 files
IAD2.zip 24000 files
IAD3.zip 32000 files
.....
Run Code Online (Sandbox Code Playgroud)
命令行
zipinfo IAD${count}.zip |grep ^-|wc -l >>TotalCount.txt
Run Code Online (Sandbox Code Playgroud)
在结果上方使用命令显示 zip 文件中的文档数:
30000
24000
32000
.....
Run Code Online (Sandbox Code Playgroud)
Dig*_*y S 10
zipinfo -h <file name> | tr '\n' ':' | awk -F':' '{print $2 , $5 , "files"}'
Run Code Online (Sandbox Code Playgroud)
解释:
zipinfo -h -- list header line. The archive name, actual size (in bytes) and total number of files is printed.
tr '\n' ':' -- Replace new line with ":"
awk -F':' '{print $2 , $5 , "files"}' -- Read file as ":" delimited and print 2nd and 5th field
Run Code Online (Sandbox Code Playgroud)
演示:
:>zipinfo test.zip
Archive: test.zip
Zip file size: 2798 bytes, number of entries: 7
-rw-r--r-- 3.0 unx 18 tx stor 20-Mar-10 13:00 file1.dat
-rw-r--r-- 3.0 unx 32 tx defN 20-Mar-10 13:00 file2.dat
-rw-r--r-- 3.0 unx 16 tx stor 20-Mar-10 12:26 file3.dat
-rw-r--r-- 3.0 unx 1073 tx defN 20-Mar-12 05:24 join1.txt
-rw-r--r-- 3.0 unx 114 tx defN 20-Mar-12 05:25 join2.txt
-rw-r--r-- 3.0 unx 254 tx defN 20-Mar-11 09:39 sample.txt
-rw-r--r-- 3.0 unx 1323 bx stor 20-Mar-14 09:14 test,zip.zip
7 files, 2830 bytes uncompressed, 1746 bytes compressed: 38.3%
:>zipinfo -h test.zip | tr '\n' ':' | awk -F':' '{print $2 , $5 , "files"}'
test.zip 7 files
Run Code Online (Sandbox Code Playgroud)