重定向操作符是限制列 [英] Redirection operator is limiting columns

查看:213
本文介绍了重定向操作符是限制列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我运行以下命令可以列出服务器上安装的软件包。

  $> dpkg的-l

这是好的,但是当我这样做

  $> dpkg的-l> list_of_packages_installed

我只得到数据的106列,其余被切断。因此,所有的行是有,但不是所有的数据列明智的。必须有简单的东西,我在这里丢失?


解决方案

变量COLUMN确实是负责这一点。的dpkg(8)的手册页包含部分下的环境:


 
         设置显示 - dpkg的时候应该使用的列数
         ING格式的文本。目前仅用于-l。


如果柱是在环境中设置的dpkg然后将使用它。你可以用
这个命令:

  ENV | grep的^柱=

如果该命令的输出类似于

 列= 80

那么你知道这个变量设置环境。
需要注意的是这个命令:

 回声$柱

不告诉你,如果它是一个环境或shell变量。列可以不被导出到环境被设置为一个shell变量。使用这个命令:

 列= $柱的dpkg -l> ķ

您明确地把变量的dpkg的环境。
如果在您的环境不是那么这将是只此命令。
还注意到,在这方面的dpkg的行为之间的不同
Ubuntu和Debian,也要看版本。已经有几
关于这一主题的错误报告。例如将设置在挤压的dpkg
列的宽度,以便所有包名和版本可以显示在全
如果柱未在环境中设置和输出不是一个tty。

问候

I am running the following command to list the packages installed on a server.

$> dpkg -l

This is fine but when I do this

$> dpkg -l > list_of_packages_installed

I only get 106 columns of data and the rest is cut off. So all the rows are there but not all the data column-wise. There must be something simple I am missing here?

解决方案

The variable COLUMN is indeed responsible for this. The manpage of dpkg(8) contains under the section "ENVIRONMENT":

   COLUMNS
         Sets  the number of columns dpkg should use when display-
         ing formatted text. Currently only used by -l.

if COLUMNS is set in your environment then dpkg will use it. You can check with this command:

env | grep ^COLUMNS=

if that command outputs something like

COLUMNS=80

then you know that this variable is set in your environment. Note that this command:

echo $COLUMNS

does not tell you if it is an environment or a shell variable. COLUMNS can be set as a shell variable without being exported to the environment. With this command:

COLUMNS=$COLUMNS dpkg -l > k

you explicitely put the variable in the environment of dpkg. If it was not in your environment then it will be for this command only. Also note that the behaviour of dpkg in this respect is different between ubuntu and debian and also depends on the version. There have been a few bug reports on this topic. The dpkg in squeeze for example will set the column width so that all package names and version can be displayed in full if COLUMNS is not set in the environment and the output is not a tty.

Regards

这篇关于重定向操作符是限制列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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