Skip to content

Instantly share code, notes, and snippets.

@phts
Created November 2, 2024 12:12
Show Gist options
  • Select an option

  • Save phts/ed1a15bc4d6a3112b0d4336836912eaa to your computer and use it in GitHub Desktop.

Select an option

Save phts/ed1a15bc4d6a3112b0d4336836912eaa to your computer and use it in GitHub Desktop.
Bash conditions
# 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