How To Write Bash Scripts In Linux - Complete Guide (Part 5 - If Statements)
Learn Linux TV
@learnlinuxtvAbout
Learn Linux TV is your ultimate resource for mastering Linux and open-source technology. From step-by-step Linux tutorials and distro reviews to server automation, cloud deployments, security, and DevOps workflows, this channel gives you the skills to thrive in today’s Linux Community. With over 20 years of Linux and System Administration experience, Jay (your host) shares practical insights to help you succeed with Linux — whether at home, in the data center, or in the cloud. Whether it’s Debian, Ubuntu, Fedora, Arch, or Proxmox, you’ll learn how to build, secure, and manage systems with confidence! • Linux made simple: tutorials, reviews, and sysadmin tips you can actually use. • Your go-to channel for Linux tutorials, distro reviews, and real-world sysadmin skills. • Where beginners become power users, and pros sharpen their Linux skills. Subscribe and join a community of hundreds of thousands of Linux enthusiasts who are learning, building, and growing with open source.
Latest Posts
Video Description
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
Essential Gear for Photographers
AI-recommended products based on this video

SmallRig Z 8 L-Bracket for Nikon Z8 Z 8 Camera, Quick Release L Plate for Arca-Type for Nikon Z 8, Quick Switch Between Horizontal and Vertical Shooting, for Landscape, Animal Photography - 3942

NEEWER Zf Handgrip L Shape Grip for Nikon Z f, Ultra Thin Retro Formfitting Camera Mounting Baseplate with Handle & Aluminum Shutter Button Cap, Compatible with Arca Swiss Tripod Fluid Head, CA073

NEEWER CA076 Zfc Handgrip L Shape Grip for Nikon Z fc, Ultra Thin Retro Formfitting Camera Mounting Baseplate with Handle/Brass Shutter Button, Compatible with Arca Swiss Tripod Fluid Head, Black

SmallRig ZV-E1 Camera Baseplate for Sony ZV-E1, Built-in Cold Shoe Mount and QR Plate (for Arca) Quick Switch Between Tripod and Stabilizer for DJI RS 2 / RSC 2 / RS 3 / RS 3 Pro - 4314

SmallRig FX3 / FX30 HawkLock Quick Release Camera Cage Kit for Sony with Cable Clamp, Bulit-in QR Cold Shoe NATO Rail/QR Plate for Arca, Modular Design Compatible with Original XLR Handle - 4770

SmallRig FX3 / FX30 HawkLock Quick Release Camera Cage Kit for Sony with XLR Handle Extension, Wrist Strap and Cable Clamp for HDMI, QR Cold Shoe, NATO Rail/QR Plate for Arca,Titanium Gray - 4771

AC Power Cord Cable Fit for Sony PS5 PS4 PS3 Slim PlayStation 5 4 3, Xbox Series X/S, Xbox One X/S, TV, Printer Universal 2 Prong Supply Replacement - (ETL Listed Cable)

SanDisk 64GB Extreme PRO SDXC UHS-I Memory Card - C10, U3, V30, 4K UHD, SD Card - SDSDXXU-064G-GN4IN

SanDisk 128GB Extreme PRO SDXC UHS-I Memory Card - C10, U3, V30, 4K UHD, SD Card - SDSDXXD-128G-GN4IN




















