Answers for "if statement in shell script"

23

bash if statement

and - &&
or - ||

# and example
if [ -r $1 ] && [ -s $1 ]
then
echo This file is useful.
fi

# or example
if [ $USER == 'bob' ] || [ $USER == 'andy' ]
then
ls -alh
else
ls
fi
Posted by: Guest on February-21-2020
3

if else statement example in shell script

if [ ... ]
then
  # if-code
else
  # else-code
fi
Posted by: Guest on May-08-2021
7

if and if bash

if [ "${STATUS}" != 200 ] && [ "${STRING}" != "${VALUE}" ]; then
Posted by: Guest on May-23-2020
2

bash if

#!/bin/bash

foo="qux"
bar="qux"

if [ "$foo" = "$bar" ]; then
    echo "The strings are equal."
else
    echo "The strings aren't equal."
fi
Posted by: Guest on September-14-2020
1

ash if statment

if [ "$USER" == "Adam" ]
then
	echo "User is Adam"
else
	echo "User is not Adam"
fi
Posted by: Guest on July-27-2020
0

if statement in shell script

if [ "$result" == "1" ]
    then 
      echo "test" >> /home/samurai/test.txt
    fi
    

    
    if [[ "$result" -eq "1" ]]
    then 
      echo "test" >> /home/samurai/test.txt
    fi
Posted by: Guest on August-12-2021

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language