Created
November 2, 2024 12:12
-
-
Save phts/ed1a15bc4d6a3112b0d4336836912eaa to your computer and use it in GitHub Desktop.
Bash conditions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # numbers | |
| if [ $var -ge 3 ]; then # >= 3 | |
| if [ $var -gt 3 ]; then # > 3 | |
| if [ $var -lt 3 ]; then # < 3 | |
| if [ $var -le 3 ]; then # <= 3 | |
| if [ $var -eq 3 ]; then # == 3 | |
| # strings | |
| if [ -z "$str" ]; then # if empty string | |
| if [ "$str1" == "$str2" ]; then | |
| # fs | |
| if [ -f $file ]; then # file exists | |
| if [ -к $file ]; then # readable file | |
| if [ -L $file ]; then # if sym link | |
| # extra | |
| if [[ "$str" == *[sS]tring* ]]; then # any glob | |
| if [[ <cond1> && <cond2> ]]; then | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment