Skip to content

Commit

Permalink
Add examples of one liner if-else conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
josephpaul0 authored Mar 30, 2024
1 parent 641915c commit 88c55d8
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions bash.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 88c55d8

Please sign in to comment.