What is the benefit of using $() instead of backticks in shell scripts?

后端 未结 8 1014
梦谈多话
梦谈多话 2020-11-22 05:05

There are two ways to capture the output of command line in bash:

  1. Legacy Bourne shell backticks ``:

    var=`command`
             
    
    
            
8条回答
  •  悲哀的现实
    2020-11-22 05:37

    In addition to the other answers,

    $(...)
    

    stands out visually better than

    `...`
    

    Backticks look too much like apostrophes; this varies depending on the font you're using.

    (And, as I just noticed, backticks are a lot harder to enter in inline code samples.)

提交回复
热议问题