From 88c55d8a567bc0a66ce46f7e0c395a8fe7deee67 Mon Sep 17 00:00:00 2001 From: Joseph Paul Date: Sat, 30 Mar 2024 22:35:08 +0100 Subject: [PATCH] Add examples of one liner if-else conditions --- bash.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bash.md b/bash.md index dec1310281..712ec5ea11 100644 --- a/bash.md +++ b/bash.md @@ -99,6 +99,8 @@ if [[ -z "$string" ]]; then elif [[ -n "$string" ]]; then echo "String is not empty" fi +[[ -z ${string} ]] && echo "String is empty" # one line if condition +[[ $? -eq 0 ]] || echo "Instruction failed" # one line else condition ``` See: [Conditionals](#conditionals)