Linux 这四个命令之间有什么区别?

Linux 这四个命令之间有什么区别?,linux,bash,redirect,Linux,Bash,Redirect,ls-yz 1>&22>命令日志 ls: invalid option -- 'y' Try 'ls --help' for more information. ls: invalid option -- 'y' Try 'ls --help' for more information. 控制台中没有输出,它在命令.log中 ls: invalid option -- 'y' Try 'ls --help' for more information. ls: invalid option

ls-yz 1>&22>命令日志

ls: invalid option -- 'y'
Try 'ls --help' for more information.
ls: invalid option -- 'y'
Try 'ls --help' for more information.
控制台中没有输出,它在
命令.log中

ls: invalid option -- 'y'
Try 'ls --help' for more information.
ls: invalid option -- 'y'
Try 'ls --help' for more information.
  • ls-yz 1>&2 1>命令日志

    ls: invalid option -- 'y'
    Try 'ls --help' for more information.
    
    ls: invalid option -- 'y'
    Try 'ls --help' for more information.
    
  • ls-yz2>&12>命令日志

    ls: invalid option -- 'y'
    Try 'ls --help' for more information.
    
    ls: invalid option -- 'y'
    Try 'ls --help' for more information.
    
    控制台中没有输出,它在
    命令.log中

    ls: invalid option -- 'y'
    Try 'ls --help' for more information.
    
    ls: invalid option -- 'y'
    Try 'ls --help' for more information.
    
  • ls-yz2>&11>命令日志

    ls: invalid option -- 'y'
    Try 'ls --help' for more information.
    
    ls: invalid option -- 'y'
    Try 'ls --help' for more information.
    

  • ls-yz
    仅在标准错误时生成输出,因此作为这四种情况的一般规则,标准输出(文件描述符1)指向什么并不重要

  • 标准错误被重定向到
    command.log
    ,因此您可以在其中获得输出

  • 您将标准输出重定向两次:首先重定向到标准错误指向的对象(控制台),然后重定向到
    command.log
    ,但标准输出中不会写入任何内容。该命令相当于

    ls-yz>command.log
    
    但重定向并不重要,因为输出只写入标准错误

  • 您将标准错误重定向两次:首先重定向到标准输出指向的对象(控制台),然后重定向到
    command.log
    。该命令相当于

    ls-yz 2>command.log
    
  • 将标准错误重定向到标准输出所指向的(控制台),然后才将标准输出重定向到
    command.log
    。标准错误仍然重定向到控制台

  • Bash黑客维基有一个很好的功能