./What_is_BASH?!.sh

mike_in_tech

Michael Briseno

Posted on August 28, 2023

./What_is_BASH?!.sh

Tired of doing boring, repetitive tasks? BASH scripting is a powerful way to automate those tasks and manipulate data on Linux systems. BASH stands for Bourne Again Shell (no relation to Jason Bourne), which is a command-line interpreter that can execute commands from a file or interactively from the terminal.

JBourne

What is a BASH script?

A BASH script is simply a file that holds a bunch of Linux commands and when you run the script it will run the commands in order from top to bottom. A bash script can also use variables, functions, loops, conditional statements, and other features to create more complex and dynamic scripts.

To create a BASH script, you need to follow these steps:

  1. Create a file, you can use the extension .sh but it is not necessary. Use any text editor to write your script. For example, you can use nano, or vim.

  2. Start your script with a SHEBANG line, which tells the system what scripting language will be used to run the script. The shebang line is usually #!/bin/bash for BASH scripts.

Shebangs

  1. Fill your file with commands in the order you want them executed.

  2. To be able to run your script you must make your script executable by using the chmod command. For example, chmod +x my_script.sh. (you can also type "bash my_script.sh" to run it without getting executable permission)

  3. Run your script by typing its name or its full path in the terminal. For example, ./my_script.sh or /home/user/my_script.sh. Depending where you are in your directory.

Conclusion

Bash scripting is a useful skill that can help you automate tasks and manipulate data on Linux systems. Thanks for stopping by to read and learn some basics of BASH, check out the resources below to learn more about BASH!

RESOURCES

Here are some great YouTube personalities/ resources to try to learn more BASH from.

  1. NETWORK CHUCK BASH SERIES - great place to start
  2. Shawn Powers BASH series - easy to follow examples
  3. Devhints.io BASH Cheat Sheet
  4. Learn Linux TV Bash Series - Longer series than others, covers a lot with examples covering backingup and scheduling jobs
  5. Scott Simpson Linkedin Learning BASH scripting Course - MUST HAVE Linkedin Premium - Provides Git Repo that you can fork and use Gits Codespaces to follow along!
  6. Microsoft Developer Bash for Beginners
💖 💪 🙅 🚩
mike_in_tech
Michael Briseno

Posted on August 28, 2023

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

./What_is_BASH?!.sh
bash ./What_is_BASH?!.sh

August 28, 2023