V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
James369
V2EX  ›  Linux

less 命令在与管道工作时,为什么会自动退出交互模式?

  •  
  •   James369 · Dec 18, 2020 · 1813 views
    This topic created in 1964 days ago, the information mentioned may be changed or developed.
    当直接 less xxx 文件时,是处于一种交互模式,即可以进行上下翻页操作。
    但是在 less xxx | grep yyy 时,它就会自动退出交互模式,而直接将文件全部内容输出到 grep 命令。

    less 命令是如何识别到当前所处的执行环境的?
    3 replies    2020-12-18 10:56:44 +08:00
    lululau
        1
    lululau  
       Dec 18, 2020   ❤️ 1
    man 3 isatty
    codehz
        2
    codehz  
       Dec 18, 2020 via Android   ❤️ 1
    James369
        3
    James369  
    OP
       Dec 18, 2020
    明白了,漂亮。。。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2820 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 12:53 · PVG 20:53 · LAX 05:53 · JFK 08:53
    ♥ Do have faith in what you're doing.