方式一
命令:
unzip -v test.zip | grep 'Stored' |awk '{print $8}'
效果如下:
$ unzip -v test.zip | grep 'Stored' |awk '{print $8}'
test1/
test2/
test3/
可以看到test.zip中一共压缩了三个文件夹内容,打印出来的结果为 test1/ 这种形式,如果想要直接得到 test1 文件夹名需要再使用管道符多进行一步的处理。
方式二
命令如下:
unzip -v test.zip | grep 'Stored' |awk '{print $8}' |sed 's!/!!'
效果:
$ unzip -v test.zip | grep 'Stored' |awk '{print $8}' |sed 's!/!!'
test1
test2
test3