From 898c8d904b15a1346b58ebfa5fc213518f3413d7 Mon Sep 17 00:00:00 2001 From: Seth <402885+Setheck@users.noreply.github.com> Date: Fri, 16 Nov 2018 12:08:34 -0800 Subject: [PATCH] Bash correction (#922) * fix bash path split example * add two string equality and example --- bash.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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" =~ "." ]]