清单一个tar文件或目录的内容只下降到一定程度 [英] Listing the content of a tar file or a directory only down to some level

查看:147
本文介绍了清单一个tar文件或目录的内容只下降到一定程度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不知如何列出一个tar文件的内容只下降到一定程度?

我理解焦油TVF mytar.tar 将列出所有的文件,但有时我想只能看到目录下到一定程度。

同样,对于命令 LS ,我怎么控制将显示的子目录的水平?默认情况下,它只会显示直接子目录,但不能走得更远。


解决方案

 焦油TVF scripts.tar | awk的-F /'{如果(NF 4;)打印}'
drwx ------峡谷/峡谷0 2010-03-17 10:44脚本/
-rwxr - R--峡谷/ www数据1051 2009-07-27 10:42脚本/ my2cnf.pl
-rwxr - R--峡谷/ www数据359 2009-08-14 00:01脚本/ pastebin.sh
-rwxr - R--峡谷/ www数据566 2009-07-27 10:42脚本/ critic.pl
-rwxr-XR-X峡谷/峡谷981 2009-12-16 09:39脚本/ wiki_sys.pl
-rwxr-XR-X峡谷/峡谷3072 2009-07-28 10:25脚本/ blacklist_update.pl
-rwxr - R--峡谷/ www数据18418 2009-07-27 10:42脚本/ sysinfo.pl

请一定要注意,这个号码是3+你想要但是许多层面,因为用户名/组/中。如果你只是做

 焦油TF scripts.tar | awk的-F /'{如果(NF 3;)打印}'脚本/
脚本/ my2cnf.pl
脚本/ pastebin.sh
脚本/ critic.pl
脚本/ wiki_sys.pl
脚本/ blacklist_update.pl
脚本/ sysinfo.pl

只有两个是。

您可以 LS -R 大概管道输出到这个 AWK 脚本,并有同样的效果。

I wonder how to list the content of a tar file only down to some level?

I understand tar tvf mytar.tar will list all files, but sometimes I would like to only see directories down to some level.

Similarly, for the command ls, how do I control the level of subdirectories that will be displayed? By default, it will only show the direct subdirectories, but not go further.

解决方案

tar tvf scripts.tar | awk -F/ '{if (NF<4) print }'


drwx------ glens/glens       0 2010-03-17 10:44 scripts/
-rwxr--r-- glens/www-data 1051 2009-07-27 10:42 scripts/my2cnf.pl
-rwxr--r-- glens/www-data  359 2009-08-14 00:01 scripts/pastebin.sh
-rwxr--r-- glens/www-data  566 2009-07-27 10:42 scripts/critic.pl
-rwxr-xr-x glens/glens     981 2009-12-16 09:39 scripts/wiki_sys.pl
-rwxr-xr-x glens/glens    3072 2009-07-28 10:25 scripts/blacklist_update.pl
-rwxr--r-- glens/www-data 18418 2009-07-27 10:42 scripts/sysinfo.pl

Make sure to note, that the number is 3+ however many levels you want, because of the / in the username/group. If you just do

tar tf scripts.tar | awk -F/ '{if (NF<3) print }'

scripts/
scripts/my2cnf.pl
scripts/pastebin.sh
scripts/critic.pl
scripts/wiki_sys.pl
scripts/blacklist_update.pl
scripts/sysinfo.pl

it's only two more.

You could probably pipe the output of ls -R to this awk script, and have the same effect.

这篇关于清单一个tar文件或目录的内容只下降到一定程度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆