有没有办法在使用 dpkg -L 列出包的文件时列出文件数?

shi*_*ish 1 shell zsh debian dpkg

cat -n用来获取.txt文件中内容的行列表。

[$] cat exam.txt                                                                                                                    
     1  let's see how far does this go, and if it works or not. if not till where it 
     2  goes and what happens after that. In nano, things are much more better than in X 
     3  text editors as there is no set fill therein as there is in nano and hence are 
     4  much worse off. 
Run Code Online (Sandbox Code Playgroud)

在 dpkg 中似乎没有这样做,或者有吗?我正在 Debian 测试并运行 dpkg 1.18.18 。只是为了使列表不那么麻烦,我使用 head -

[$] dpkg -L nano | head

/.
/bin
/bin/nano
/etc
/etc/nanorc
/usr
/usr/share
/usr/share/doc
/usr/share/doc/nano
/usr/share/doc/nano/AUTHORS
Run Code Online (Sandbox Code Playgroud)

因为我正在使用 head 我知道这些是 10 行或 10 个文件,考虑到 . 也作为文件。我确实尝试过类似 -

$ dpkg -nL nano 
Run Code Online (Sandbox Code Playgroud)

但是得到了它不知道该选项的错误。

如果不可能,请告诉我,以便我可以将其作为功能请求在dpkg.

Ste*_*itt 5

dpkg -L nano | cat -n
Run Code Online (Sandbox Code Playgroud)

有诀窍......(虽然它计算目录和文件。)

如果你只想要总数,

dpkg -L nano | wc -l
Run Code Online (Sandbox Code Playgroud)

  • 另一个在 coreutils 中进行行编号的应用程序是 `nl`。 (2认同)