根据这里的答案,我能够以ls
格式列出我的 tarball 的内容。但是,我希望能够以tree
格式列出它们,即类似于后者而不是前者:
与tar
:
$ tar -tf foo.tar
foo/
foo/baz/
foo/baz/qux/
foo/baz/qux/hisfile.txt
foo/bar/
foo/bar/myfile.txt
foo/bar/yourfile.txt
Run Code Online (Sandbox Code Playgroud)
与tree
:
$ tree foo
foo
??? bar
? ??? myfile.txt
? ??? yourfile.txt
??? baz
??? qux
??? hisfile.txt
Run Code Online (Sandbox Code Playgroud)
是否可以在不提取 tarball 的情况下执行此操作?由于它们的大小,我更愿意避免提取tarball。
有几个脚本可以将路径名列表转换为树形式:
所有这些脚本都与tar -tf …
输出一起工作;例如:
$ tar -tf foo.tar | 树化 富 ??酒吧 ? ??myfile.txt ? ??您的文件.txt ??baz ??qux ??hisfile.txt
还:
$ bsdtar -tf foo.zip | treeify
$ find /dir -size +5 | treeify
$ git ls-files | treeify
$ pacman -Qql foopkg | treeify
$ unrar vb foo.rar | treeify
$ zipinfo -1 foo.zip | treeify
$ gsettings list-schemas | treeify -s. -f
$ qdbus | sed -n "s/^ //p" | treeify -s. -f
$ ldns-walk netbsd.org | awk '{print $1}' | treeify -s. -f -R
Run Code Online (Sandbox Code Playgroud)
尽管我没有足够的声誉来发表评论,但这只是 user1686 答案的附录。虽然他的脚本确实可以很好地完成这项工作,但它们需要下载而tree
实际上可以在本机执行此操作:
$ tar tf foo.tar | tree --fromfile .
.
??? foo
??? bar
? ??? myfile.txt
? ??? yourfile.txt
??? baz
??? qux
??? hisfile.txt
4 directories, 3 files
Run Code Online (Sandbox Code Playgroud)
请注意,与大多数工具不同的是,tree
使用点.
而不是破折号-
从 stdin 读取输入:
INPUT OPTIONS
--fromfile
Reads a directory listing from a file rather than the file-system.
Paths provided on the command line are files to read from rather than directories to search.
The dot (.) directory indicates that tree should read paths from standard input.
Run Code Online (Sandbox Code Playgroud)
这允许使用通配符等典型的树函数,尽管显然无法显示大小并且级别参数 ( -L
) 显然也不起作用......
归档时间: |
|
查看次数: |
3619 次 |
最近记录: |