3. Running Multiple command in one line
Some time we need to run multiple command at once, for this we have various
option to separate our list of commands. These separators has different effect on
execution.
We have following operators to separate the commands
1. &&(and) : True if preceding command returns true value
2. ||(or) : Runs all the commands
3. ;(semi-colon) : Run Commands sequentially
4. & (ampersand): Run a command in background
4. Example running command
1. false || echo "This will Print/run"
This will Print
[ -f file1 ] || echo "File does not Exist: This will return false and this will
print"
2. true || echo "This will not print/run"
[ -f file ] || echo "File Exist: This will return true and this will not print"
3. true && echo "This will print/run"
This will print
[ -f file ] && echo "File does Exist: This will return true and this will print"
4. false && echo "This will not print/run"
[ -f file1 ] && echo "File does not Exist: This will return false and this will
not print"
5. false ; echo "This will always Print/run"
This will always run
[ -f file1 ];[ -f file ];echo "This will bring sequentially”
6. example_shell_script.sh &
Above script will run in background
5. Thanks For Watching TechGurukul
Please support our channel by just liking Subscribing and pressing bell icon to
keep in touch
dwivedishashwat@gmail.com