more, less 表现得像猫
more, less are behaving like cat
在 KVM 主机上安装新的 RHEL 时,我正在使用 more
命令显示一个文本文件。问题是 more
在 virt-manager 中表现得像 cat
,即不逐页显示并直接滚动到页面末尾。我尝试使用 less
而不是 more
但它显示相同的行为。
任何人都可以提出这可能是什么原因吗?
编辑 根据评论,我尝试在首次启动时将 TERM 更改为 xterm。但这没有任何效果。我试过这个命令 export TERM=xterm
我打印了环境变量。我正在粘贴它,希望这可能是一个线索。
编辑 我无法让它工作。我注意到在执行脚本之前,其他一些脚本是 运行 并且这可能正在设置一些环境变量,因此 more
无法正常工作。我现在在这个脚本开始执行之前调用更多命令。现在它正在工作。
我怀疑你的环境不对。具体来说,您的 $TERM
环境变量可能未设置。 more
手动输入见 here。
The more command respects the following environment variables, if
they exist:
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.
在高级开发人员的帮助下,我发现了幕后发生的事情。
假设 A.sh 正在执行如下 more
命令:
more pathtofile
A.sh 正被其他脚本调用,如下所示:
pathtoA.sh | tee
由于此 tee
命令,子脚本中的 more
命令未按应有的方式运行。
在 KVM 主机上安装新的 RHEL 时,我正在使用 more
命令显示一个文本文件。问题是 more
在 virt-manager 中表现得像 cat
,即不逐页显示并直接滚动到页面末尾。我尝试使用 less
而不是 more
但它显示相同的行为。
任何人都可以提出这可能是什么原因吗?
编辑 根据评论,我尝试在首次启动时将 TERM 更改为 xterm。但这没有任何效果。我试过这个命令 export TERM=xterm
我打印了环境变量。我正在粘贴它,希望这可能是一个线索。
编辑 我无法让它工作。我注意到在执行脚本之前,其他一些脚本是 运行 并且这可能正在设置一些环境变量,因此 more
无法正常工作。我现在在这个脚本开始执行之前调用更多命令。现在它正在工作。
我怀疑你的环境不对。具体来说,您的 $TERM
环境变量可能未设置。 more
手动输入见 here。
The more command respects the following environment variables, if they exist:
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.
在高级开发人员的帮助下,我发现了幕后发生的事情。
假设 A.sh 正在执行如下 more
命令:
more pathtofile
A.sh 正被其他脚本调用,如下所示:
pathtoA.sh | tee
由于此 tee
命令,子脚本中的 more
命令未按应有的方式运行。