Skip to content

Instantly share code, notes, and snippets.

@fcojperez
Created March 14, 2023 09:25
Show Gist options
  • Select an option

  • Save fcojperez/abeba9f60ee11b127f74268016ab1f12 to your computer and use it in GitHub Desktop.

Select an option

Save fcojperez/abeba9f60ee11b127f74268016ab1f12 to your computer and use it in GitHub Desktop.

Revisions

  1. fcojperez renamed this gist Mar 14, 2023. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. fcojperez created this gist Mar 14, 2023.
    7 changes: 7 additions & 0 deletions bash_ternary
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    #### Bash does not have a native ternary operator. Instead, the same functionality can be achieved using:

    color="blue"
    [[ "$color" == "blue" ]] && echo "🟦" || echo "🟩"
    # Output: 🟦

    ### More information here, https://how.wtf/ternary-operator-in-bash.html#ternary-operation