Summary
Keywords
Full Transcript
Learn how to use If statements in Bash scripting with this beginner-friendly tutorial! In this episode of LearnLinuxTV’s complete Bash Scripting course, you’ll discover how conditional logic works in Bash. We’ll cover how to structure If statements, when to use them, and why they’re essential for creating decision-making scripts. With clear explanations and practical examples, this video will help you level up your scripting skills and write smarter, more dynamic Bash scripts. *Brand New Ansible Course Available* Check out the new course on Udemy! It covers everything you need to get started with Automation. ➜ https://learnlinux.link/ansible *Individual Sections* 00:00 - Pre-Intro 00:48 - Intro 01:13 - Understanding "If Statements" in Bash and why they're useful 01:42 - An example of an If Statement within a Bash Script on Linux 04:43 - Marking the script executable and running it 07:19 - Creating an If/Else conditional in Bash 12:07 - Using an If Statement in a Bash Script to check for the existence of a file 14:22 - Further explanation of checking for the existence of files and directories on Linux 15:20 - Using the which command on Linux to check if a command is present 16:19 - Creating a Bash Script to install a package if it's not already installed 21:52 - How to use the apt command inside a Bash Script on Linux 23:02 - Using the -y option with apt to assume yes (bypass/skip prompts) *OTHER BASH SCRIPTING SERIES EPISODES* - Class 01 ➜ Introduction: https://linux.video/bash1 - Class 02 ➜ Hello World: https://linux.video/bash2 - Class 03 ➜ Variables: https://linux.video/bash3 - Class 04 ➜ Math Functions: https://linux.video/bash4 - Class 05 ➜ If Statements: https://linux.video/bash5 - Class 06 ➜ Exit Codes: https://linux.video/bash6 - Class 07 ➜ While Loops: https://linux.video/bash7 - Class 08 ➜ Universal Update Script: https://linux.video/bash8 - Class 09 ➜ For Loops: https://linux.video/bash9 - Class 10 ➜ Where To Store Your Scripts: https://linux.video/bash10 - Class 11 ➜ Data Streams: https://linux.video/bash11 - Class 12 ➜ Functions: https://linux.video/bash12 - Class 13 ➜ Case Statements: https://linux.video/bash13 - Class 14 ➜ Scheduling Jobs (Part 1): https://linux.video/bash14 - Class 15 ➜ Scheduling Jobs (Part 2): https://linux.video/bash15 - Class 16 ➜ Arguments: https://linux.video/bash16 - Class 17 ➜ Building a Backup Script: https://linux.video/bash17 - Class 18 ➜ Closing: https://linux.video/bash18 *🎓 More About Learn Linux TV* • Main site ➜ https://www.learnlinux.tv • Community Forums ➜ https://community.learnlinux.tv • Github Account ➜ https://github.com/LearnLinuxTV • Content Ethics ➜ https://www.learnlinux.tv/content-ethics • Request Paid Assistance ➜ https://www.learnlinux.tv/request-assistance Learn Linux TV provides technical content that will hopefully be helpful to you and teach you something new. However, this content is provided without any warranty (expressed or implied). Learn Linux TV is not responsible for any damages that may arise from any use of this content. The person viewing Learn Linux TV's content is expected to follow their best judgement and to make their best decisions while working with any related technology. Always make sure you have written permission before working with any infrastructure. Also, be sure that you're compliant with all company rules, change control procedures, and local laws. #commandline #linuxtutorial #bash
