Learn Basic Bash Scripting in One Month
How to Learn Basic Bash Scripting in One Month
A simple, hands-on plan for absolute beginners
1. What Bash scripting is and why it matters
Bash is the command language used in Linux, macOS, many servers, and high-performance computing
clusters. A Bash script is simply a text file containing terminal commands that run automatically in order.
The goal in the first month is not to become a system administrator. The goal is to become comfortable
automating small, repeated tasks.
Use Bash to rename files, move data, count lines, search text, run programs, and organize folders.
Think of every script as a recipe: input files go in, commands process them, and useful output comes out.
Learn by typing commands yourself. Do not only watch tutorials; Bash becomes clear through repetition.
2. Tools to install before Day 1
System Recommended setup First check command
Linux Use the built-in terminal. bash --version
Use Terminal or iTerm2. Install
macOS echo $SHELL
Homebrew later if needed.
Install WSL Ubuntu, or use Git Bash
Windows pwd
for basics.
3. Your daily 30-minute practice routine
1. 5 minutes: revise yesterday’s commands without looking at notes.
2. 10 minutes: learn one new concept and type 5–10 examples.
3. 10 minutes: write or edit one small script.
4. 5 minutes: record what worked, what failed, and one command to remember.
4. Core terminal commands for the first week
Task Command Example Meaning
Where am I? pwd pwd Print current folder
List files ls ls -lh Show file sizes clearly
Move around cd cd project Enter a folder
Make folder mkdir mkdir results Create directory
Copy file cp cp [Link] backup/ Copy data safely
Search text grep grep "error" [Link] Find matching lines
Rule for beginners: never run rm -rf or sudo commands copied from the internet unless you fully
understand them. Practice first in a test folder.
A practical 30-day beginner roadmap
Learn Basic Bash Scripting in One Month
5. One-month roadmap
The plan below is deliberately practical. Each week ends with a mini-project, because scripting skill grows
fastest when you solve small real problems.
Week Main goal Must-learn topics Mini-project
Week 1 Move confidently in the pwd, ls, cd, mkdir, cp, mv, Create folders and sort practice
terminal. grep, head, tail files.
Week 2 Write simple scripts. shebang, chmod, variables, Make a backup script for one
echo, quoting, comments folder.
Week 3 Control logic. if/else, tests, loops, arguments, Process every .txt file in a
exit status folder.
Week 4 Build reliable scripts. functions, logging, errors, Final script that organizes and
pipes, small automation summarizes files.
6. Basic script structure
A Bash script usually starts with a shebang line, then contains variables, commands, and optional logic. Save
the file as something like [Link], give it permission, and run it.
#!/usr/bin/env bash
name="Subhajit"
echo "Hello, $name"
echo "Today is: $(date)"
Run it: chmod +x [Link] && ./[Link]
7. Concepts you must understand clearly
Variables: Store text or paths: folder="data". Use $folder to read the value.
Quoting: Use double quotes around variables: "$file". This prevents spaces in filenames from breaking scripts.
Exit status: Every command returns success or failure. 0 means success; non-zero means failure.
Pipes: Use command1 | command2 to pass output from one command into another.
Arguments: $1, $2, and $3 are values given to the script when it is run.
8. Practice scripts for Week 2 and Week 3
Script idea What it teaches
[Link]: copy one folder to backup_YYYY-MM-DD Variables, date command, cp -r, safe paths
count_lines.sh: count lines in every .txt file for loop, wc -l, wildcards
check_file.sh: test whether a file exists if statement, test operators, clear messages
search_logs.sh: find ERROR lines in log files grep, loops, redirecting output
A practical 30-day beginner roadmap
Learn Basic Bash Scripting in One Month
9. Small scripts to copy, run, and modify
The fastest way to learn is to start with short working scripts and then modify them. Create a safe practice
folder before testing.
Script A: check whether a file exists
#!/usr/bin/env bash
file="$1"
if [[ -f "$file" ]]; then
echo "Found: $file"
else
echo "Missing file: $file"
fi
Script B: loop through text files
#!/usr/bin/env bash
for file in *.txt; do
echo "Processing $file"
wc -l "$file"
done
10. Final Week 4 project: file organizer
Your final beginner project is a script that creates folders and moves files by type. This is realistic, useful,
and small enough to finish in one week.
Create folders named PDFs, Images, Text, Scripts, and Other.
Move .pdf files to PDFs, .png/.jpg files to Images, .txt files to Text, and .sh files to Scripts.
Print a summary at the end: how many files were moved into each folder.
Add safety: if a folder already exists, do not crash; if no matching files exist, print a calm message.
11. Common beginner mistakes
Mistake Better habit
Forgetting quotes around variables Use "$file" almost always.
Editing scripts directly on important files Create a practice folder and copy sample files.
Trying to memorize everything Keep a command cheat sheet and practice daily.
Ignoring error messages Read the first error carefully; it often tells the exact problem.
12. End-of-month self-test
1. Can you create a folder, move files, and list the result without help?
2. Can you write a script with a shebang, variables, and comments?
3. Can you use if/else to check whether a file exists?
4. Can you use a for loop to process multiple files?
5. Can you explain why quoting "$variable" is important?
Success target: after one month, you should be able to write small scripts that save time in your own
work. Fluency comes later, but useful automation can start immediately.
A practical 30-day beginner roadmap