Comparación de números enteros
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
#!/bin/bash if [ "$a" -eq "$b" ]; then echo "\$a es IGUAL que \$b" fi if [ "$a" -ne "$b" ]; then echo "\$a NO ES IGUAL que \$b" fi if [ "$a" -gt "$b" ]; then echo "\$a es MAYOR que \$b" fi if [ "$a" -lt "$b" ]; then echo "\$a es MENOR que \$b" fi if [ "$a" -ge "$b" ]; then echo "\$a es MAYOR O IGUAL que \$b" fi if [ "$a" -le "$b" ]; then echo "\$a es MENOR O IGUAL que \$b" fi |
Comparación de cadenas de texto
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
#!/bin/bash if [ "$a" = "$b" ]; then echo "\$a es IGUAL que \$b" fi if [ "$a" == "$b" ]; then echo "\$a es IGUAL que \$b" fi if [ "$a" != "$b" ]; then echo "\$a NO ES IGUAL que \$b" fi if [ "$a" \> "$b" ]; then echo "\$a es MAYOR que \$b" fi if [ "$a" \< "$b" ]; then echo "\$a es MENOR que \$b" fi if [ -z "$a" ]; then echo "\$a ES NULO" fi if [ -n "$a" ]; then echo "\$a NO ES NULO" fi |