Is double square brackets [[ ]] preferable over single square brackets [ ] in Bash?

前端 未结 9 2056
情话喂你
情话喂你 2020-11-22 03:58

A co-worker claimed recently in a code review that the [[ ]] construct is to be preferred over [ ] in constructs like

if [ \"`id -         


        
9条回答
  •  不思量自难忘°
    2020-11-22 04:40

    [[ ]] has more features - I suggest you take a look at the Advanced Bash Scripting Guide for more info, specifically the extended test command section in Chapter 7. Tests.

    Incidentally, as the guide notes, [[ ]] was introduced in ksh88 (the 1988 version of the Korn shell).

提交回复
热议问题