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
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
if and if bash
if [ "${STATUS}" != 200 ] && [ "${STRING}" != "${VALUE}" ]; then
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
bash else if
if [ "$animal" == "penguin" ]; then
echo "Hmmmmmm fish... Tux happy!"
elif [ "$animal" == "dolphin" ]; then
echo "Pweetpeettreetppeterdepweet!"
else
echo "*prrrrrrrt*"
fi
if TEST-COMMANDS; then
CONSEQUENT-COMMANDS;
elif MORE-TEST-COMMANDS; then
MORE-CONSEQUENT-COMMANDS;
else
ALTERNATE-CONSEQUENT-COMMANDS;
fi
ash if statment
if [ "$USER" == "Adam" ]
then
echo "User is Adam"
else
echo "User is not Adam"
fi
bash if
#!/bin/bash
# your code goes here
echo "if double helix, type - dh "
echo "single strand, type - ss"
read htype # this is catching input
echo Structure is $htype ;
if [[ $htype == dh ]];
then
echo "##dublex#####"
else
echo "#####single#####"
fi
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us