Course overview · By Ready for Linux
Bash Scripting: Build Repeatable Linux Workflows
A script saves a sequence of commands so you can run a workflow again without retyping it. This course moves from a small saved script to arguments, decisions, and repeated work. The final project brings those pieces together in a reusable file-report script rather than asking you to memorize isolated syntax.
Before you begin
You should already know how to navigate directories, read and write files, quote filenames, and use basic command output. Complete the earlier file and text-processing courses when you need that foundation. Interactive scripting lessons require an account and an active pass that includes Bash Scripting.
What you will learn
- Save commands in a file and run them with Bash.
- Use variables and arguments to make a script reusable.
- Use conditions to handle different inputs.
- Repeat a task with a loop.
- Inspect results and recover from mistakes.
- Combine the course tools in a file-report project.
Read a filename from a script argument
# Save as show-file.sh
file="$1"
if [ -f "$file" ]; then
cat "$file"
else
printf '%s\n' "Choose an existing regular file"
fi
# Run with a file you created for practice
# bash show-file.sh notes.txtThe first argument is available as $1. The test checks whether it names a regular file, and cat displays it when the check succeeds. Quotes keep a filename containing spaces together as one argument. Run the saved script with bash show-file.sh notes.txt, substituting a practice filename. This example reads a file; it does not change it.
Course syllabus
13 lessons, from guided practice to an independent challenge.
- Save commands as a Bash script
Save familiar commands and run them together with Bash. Course access required
- Store and quote a value
Name a value once and expand it without splitting spaces. Course access required
- Understand the command environment
Locate commands and pass a named value to a child Bash process. Course access required
- Pass information into a script
Reuse the same saved commands with different input values. Course access required
- Signal success or failure
Distinguish printed output from the status a script returns. Course access required
- Test whether a regular file exists
Use test to turn a file question into an exit status. Course access required
- Choose an action with if and else
Run one set of commands when a condition is true and another when it is false. Course access required
- Check inputs and report errors
Reject incorrect argument counts without mixing error messages into useful output. Course access required
- Repeat work with a for loop
Apply the same command to each supplied value without losing spaces. Course access required
- Capture an answer from a command
Store a command's output in a variable and use it in a report. Course access required
- Name a reusable group of commands
Define a function once and call it with different values. Course access required
- Diagnose a broken script
Use syntax checks and execution tracing to repair a script, then verify varied inputs. Course access required
- Build a reusable file-report script
Combine safe inputs, file tests, captured output and useful failure behavior. Course access required
Put it into practice
Start with the earlier shell course if this example feels unfamiliar. The scripting course introduces each part separately before combining them in its final project.
Continue learning
Linux Shell Essentials: Files and Directories · Explore the full syllabus
Reference: GNU Bash manual: shell scripts.