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

Bash man stdout 问题

  •  
  •   Orzzzz · Sep 18, 2015 · 2003 views
    This topic created in 3876 days ago, the information mentioned may be changed or developed.

    下面第一行命令返回的是 whoami 的结果,但是把这行命令重定向到文件中就变成了man ls 的结果了,实在想不通,而且用管道的话 man -P whoami ls | cat 也是返回的ls的手册。想不通啊想不通!

    man -P whoami ls
    man -P whoami ls > whoami
    

    求大神指点!跪谢!

    5 replies    2015-09-19 12:43:30 +08:00
    wsy2220
        1
    wsy2220  
       Sep 18, 2015
    bash 重定向了 man 的 stdout ,没有重定向 whoami 的。
    Orzzzz
        2
    Orzzzz  
    OP
       Sep 19, 2015
    @wsy2220 我敢说你不知道上面这条命令是什么意思,甚至都没敲过。
    wsy2220
        3
    wsy2220  
       Sep 19, 2015 via Android
    @Orzzzz 说话不要太绝对好么,你 man 一下 man 看看-P 是什么意思, whoami 是 man fork 出来的, bash 当然不会重定向 whoami 的 stdout 。
    Orzzzz
        4
    Orzzzz  
    OP
       Sep 19, 2015
    `man` doesn't use a pager if the output is not a terminal but a file or a pipe. So the` -P `option is ignored in that case.

    刚在 Askubuntu 上的回答。
    Orzzzz
        5
    Orzzzz  
    OP
       Sep 19, 2015
    @wsy2220 看上条。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1016 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 18:56 · PVG 02:56 · LAX 11:56 · JFK 14:56
    ♥ Do have faith in what you're doing.