diff --git a/bash.md b/bash.md index 15e0d98e0..fd6c4f4f1 100644 --- a/bash.md +++ b/bash.md @@ -154,8 +154,8 @@ echo ${STR:-5:5} # "world" ```bash SRC="/path/to/foo.cpp" -BASE=${STR##*/} #=> "foo.cpp" (basepath) -DIR=${SRC%$BASE} #=> "/path/to" (dirpath) +BASE=${SRC##*/} #=> "foo.cpp" (basepath) +DIR=${SRC%$BASE} #=> "/path/to/" (dirpath) ``` ### Substitution @@ -333,6 +333,7 @@ Conditionals | `[ NUM -gt NUM ]` | Greater than | | `[ NUM -ge NUM ]` | Greater than or equal | | --- | --- | +| `[[ STRING == STRING ]]` | Equal | | `[[ STRING =~ STRING ]]` | Regexp | | --- | --- | | `(( NUM < NUM ))` | Numeric conditions | @@ -380,6 +381,11 @@ if [ X ] && [ Y ]; then fi ``` +```bash +# Equal +if [[ "$A" == "$B" ]] +``` + ```bash # Regex if [[ "A" =~ "." ]]