LBRY Block Explorer

LBRY Claims • bash-shell-scripting-for-beginners

2b8d50b17719d91ce2615e779ca768e0255849a1

Published By
Created On
18 Jan 2021 00:42:09 UTC
Transaction ID
Cost
Safe for Work
Free
Yes
Bash Shell Scripting For Beginners - Logical And & Logical Or
In this video we discuss the logical AND and the logical OR operators in bash.
you can get a more in depth explanation of these operators here
https://en.wikipedia.org/wiki/Logical_conjunction
***Source code for the script used in this video***
###Bash Logical Or and Logical And###

####Truth Tables###
# True = True
# False = False
# True and True = True
# True and False and True and True ... = False
# False and True = False
# False and False = False
# True or True = True
# True or False = True
# False or True or False or False ... = True
# False or False = False

true_var=true
false_var=false
#you don't have to compare a boolean variable to true, the below way is much better
if $true_var = true; then
echo 'This variable is true'
else
echo 'This variable is false'
fi

if $true_var; then
echo 'This variable is true'
else
echo 'This variable is false'
fi

if $true_var; then
echo 'This variable is true'
else
echo 'This variable is false'
fi

###Logical And

if $true_var && $false_var ; then
echo 'This variable is true'
else
echo 'This variable is false'
fi

if $false_var && $false_var ; then
echo 'This variable is true'
else
echo 'This variable is false'
fi

###Logical Or

if $true_var || $false_var ; then
echo 'This variable is true'
else
echo 'This variable is false'
fi

if $true_var || $true_var ; then
echo 'This variable is true'
else
echo 'This variable is false'
fi

***End First Script***
***realistic example of using and or***
echo "enter you age"
read age
echo "are you a felon or are you innocent?"
read criminal_status
years=$(expr 18 - $age)

if [ $age -ge 18 ] && [ $criminal_status == "innocent" ]; then
echo 'You may purchase a firearm'
elif [ $age -le 18 ] && [ $criminal_status == "innocent" ]; then
echo "You are too young kid, come back in ${years} years"
elif [ $age -le 18 ] && [ $criminal_status == "felon" ]; then
echo "You are on a bad road kid, stay in school"
elif [ $age -ge 18 ] && [ $criminal_status == "felon" ]; then
echo "You are a felon, we can't sell you a firearm!"
fi
***End of second script***

Subscribe to my YouTube channel http://goo.gl/9U10Wz
and be sure to click that notification bell so you know when new videos are released. ₿???Help Support the Channel by Donating Crypto???₿

Bitcoin
3MMKHXPQrGHEsmdHaAGD59FWhKFGeUsAxV

Ethereum
0xeA4DA3F9BAb091Eb86921CA6E41712438f4E5079

Litecoin
MBfrxLJMuw26hbVi2MjCVDFkkExz8rYvUF

Dash
Xh9PXPEy5RoLJgFDGYCDjrbXdjshMaYerz

Zcash
t1aWtU5SBpxuUWBSwDKy4gTkT2T1ZwtFvrr

Chainlink
0x0f7f21D267d2C9dbae17fd8c20012eFEA3678F14

Bitcoin Cash
qz2st00dtu9e79zrq5wshsgaxsjw299n7c69th8ryp

Etherum Classic
0xeA641e59913960f578ad39A6B4d02051A5556BfC

USD Coin
0x0B
...
https://www.youtube.com/watch?v=EYbJuvEfi7M
Author
Content Type
Unspecified
video/mp4
Language
English
Open in LBRY

More from the publisher

Controlling
VIDEO
MONER
Controlling
VIDEO
THE E
Controlling
VIDEO
THE T
Controlling
VIDEO
CONSO
Controlling
VIDEO
THE B
Controlling
VIDEO
SHELL
Controlling
VIDEO
THE T
Controlling
VIDEO
BIG T
Controlling
VIDEO
YOU N