更多,更少,表现得像猫

时间:2017-05-24 10:39:05

标签: linux virtual-machine vmware

在KVM主机上安装新的RHEL时,我使用more命令显示文本文件。问题是more在virt-manager中表现得像cat,即不逐页显示并直接滚动到页面的末尾。我尝试使用less而不是more,但它显示的是相同的行为。

有人能说出这可能是什么原因吗?

编辑根据评论,我尝试在首次启动时将TERM更改为xterm。但那没有任何效果。我尝试了这个命令export TERM=xterm

我打印了env变量。我正在粘贴它,希望这可能是一个线索。TERM-linux, PATH=xx,PWD=/,SHLVL=4,TEXTDOMAIN=vaos_init

修改我无法正常工作。我注意到在脚本执行之前,其他一些脚本正在运行,这可能是因为more无效而设置了一些环境变量。我现在在此脚本开始执行之前调用更多命令。而现在它正在发挥作用。

2 个答案:

答案 0 :(得分:2)

我怀疑你的环境不正确。具体而言,您的$TERM环境变量可能未设置。有关more手册条目,请参阅here

  

more命令遵循以下环境变量if          他们存在:

   MORE   This variable may be set with favored options to more.

   SHELL  Current shell in use (normally set by the shell at login
          time).

   TERM   The terminal type used by more to get the terminal
          characteristics necessary to manipulate the screen.

   VISUAL The editor the user prefers.  Invoked when command key v is
          pressed.

   EDITOR The editor of choice when VISUAL is not specified.

答案 1 :(得分:0)

在高级开发人员的帮助下,我发现了幕后发生的事情。

假设A.sh正在执行more命令,如下所示:

more pathtofile

A.sh被其他一些脚本调用如下:

pathtoA.sh | tee

由于这个tee命令,子脚本中的more命令的行为不应该如此。