Writing Bash Scripts

Learn how to write Bash scripts.

Throughout this course, you’ve worked with the Bash shell. You’ve used various commands and programs to work with files, directories, text, and even data over a network.

What is a Bash script?

A Bash script is a file that contains a list of commands we want the computer to execute. When we run the script, the commands will execute one at a time, sequentially, until all of the commands are run. We can use any command we’d normally type in our terminal, which means we can use everything we’ve learned about the command-line interface in a script. But Bash scripts support more than just commands. We can use variables, conditional statements, loops, and arrays. We can get input from files, pass command-line arguments, or even prompt the user for input for a more interactive ...