我有一个大小为几个GB的filename.tar.bz2文件。我想获取tar文件随附的根文件夹的UID和GID,而无需解压缩该文件的全部内容。
到目前为止,我可以使用类似的命令来检索所需的信息:
tar xjf filename.tar.bz2 --to-command 'echo $TAR_FILENAME:$TAR_UID:$TAR_GID:$TAR_UNAME:$TAR_GNAME'
...但我希望它在显示第一行(根文件夹)后停止。
有办法吗?
谢谢。
我希望它在显示第一行(根文件夹)后停止。
因此将其传送到head -n1
。
tar ..... | head -n1
tvf选项列出了信息,但没有将其拆包,如本示例所示:
tar -tvf uploadprogress.tar
-rw-r--r-- chregu/staff 2276 2011-08-15 18:51:10 package2.xml
-rw-r--r-- chregu/staff 7877 2011-08-15 18:51:10 uploadprogress/examples/index.php
-rw-r--r-- chregu/staff 1685 2011-08-15 18:51:10 uploadprogress/examples/server.php
-rw-r--r-- chregu/staff 1697 2011-08-15 18:51:10 uploadprogress/examples/info.php
-rw-r--r-- chregu/staff 367 2011-08-15 18:51:10 uploadprogress/config.m4
-rw-r--r-- chregu/staff 303 2011-08-15 18:51:10 uploadprogress/config.w32
-rw-r--r-- chregu/staff 3563 2011-08-15 18:51:10 uploadprogress/php_uploadprogress.h
-rw-r--r-- chregu/staff 15433 2011-08-15 18:51:10 uploadprogress/uploadprogress.c
-rw-r--r-- chregu/staff 1433 2011-08-15 18:51:10 package.xml