Skip to main content

Command Palette

Search for a command to run...

10 Bash Scripts That Saved Me Hours of Repetitive Work

Published
5 min read

Here’s a full draft for your blog article, shaped around your exact specifications:


Introduction - Why I Fell in Love with Bash

Let’s be honest: nobody enjoys doing the same boring task over and over. Whether it’s renaming dozens of files, backing up project folders, or checking server logs, repetitive work erodes productivity.

I still remember my early days as a developer, spending half a day manually cleaning log files. That was until I discovered the magic of Bash scripting. With just a few lines of code, I automated tasks that used to take hours - and suddenly, I felt like I had superpowers.

Bash may look intimidating to beginners, but here’s the truth: you don’t need to be a Linux guru to write scripts that can save you serious time. In this blog, I’ll share 10 Bash scripts I actually use that have saved me hours of repetitive work.

Whether you’re a beginner curious about automation, a professional who wants to save time, or just someone tired of grunt work, these examples will make you rethink how much more productive your terminal can make you.


1. Bulk Rename Files in Seconds

Ever had 100 images named IMG_001.jpg to IMG_100.jpg and needed them in a cleaner format like holiday_1.jpg, holiday_2.jpgDoing it manually is torture.

Here’s the script I use:

#!/bin/bash
counter=1
for file in *.jpg; do
  mv "$file" "holiday_$counter.jpg"
  ((counter++))
done

Use case: Perfect for organizing photos, reports, or downloaded files.

Pro Tip: You can extend this with sed or awk If you want to replace patterns inside filenames.


2. Automated Daily Backup Script

I’ve lost files before due to “I’ll back it up tomorrow” procrastination. Not anymore.

#!/bin/bash
backup_dir="/home/user/backups"
src="/home/user/projects"
timestamp=$(date +%Y%m%d_%H%M%S)
mkdir -p $backup_dir
tar -czf $backup_dir/backup_$timestamp.tar.gz $src

Use case: Automates backups for projects, documents, or databases.

Pro Tip: Add this script cron job to run automatically every night.


3. Find and Delete Temporary Files

Temporary files clutter systems faster than we realize.

#!/bin/bash
find /tmp -type f -atime +7 -delete

Use case: Clears files older than 7 days in the /tmp directory.

Why it helps: Keeps systems clean without manual effort.


4. System Health Check in One Command

Instead of running multiple commands, I built a single script:

#!/bin/bash
echo "Disk Usage:"
df -h | grep -v tmpfs
echo "Memory Usage:"
free -h
echo "Top 5 Processes:"
ps aux --sort=-%mem | head -n 6

Use case: Quick overview of system performance before deployments.

Pro Tip: Send this to a log file daily to track trends.


5. Bulk Download with wget

Imagine downloading 50 PDFs one by one. Painful.

#!/bin/bash
while read url; do
  wget "$url"
done < urls.txt

Use case: Automates downloading resources, reports, or datasets.

Pro Tip: Combine with aria2c for faster downloads.


6. Monitor a Website’s Uptime

Instead of refreshing your browser endlessly, automate it.

#!/bin/bash
url="https://example.com"
if curl -s --head "$url" | grep "200 OK" > /dev/null
then
  echo "Website is up"
else
  echo "Website is down"
fi

Use case: Basic website monitoring without fancy tools.

Advanced Tip: Pipe results to mail or slack API for alerts.


7. Git Automation for Lazy Developers (like me)

Tired of typing the same Git commands? Automate it.

#!/bin/bash
msg=$1
git add .
git commit -m "$msg"
git push origin main

Use case: One-liner Git workflow. Just run ./gitpush.sh "update message".


8. Auto-Organize Downloads Folder

If you’re like me, your downloads folder is chaos. This script sorts files by type.

#!/bin/bash
downloads=~/Downloads
mkdir -p $downloads/{Images,Docs,Videos,Others}

for file in $downloads/*; do
  case $file in
    *.jpg|*.png) mv "$file" $downloads/Images ;;
    *.pdf|*.docx) mv "$file" $downloads/Docs ;;
    *.mp4|*.mkv) mv "$file" $downloads/Videos ;;
    *) mv "$file" $downloads/Others ;;
  esac
done

Use case: Keeps folders neat automatically.


9. Log File Analyzer

Parsing log files used to take me forever. Now, it’s instant.

#!/bin/bash
logfile="/var/log/syslog"
grep "ERROR" $logfile | wc -l

Use case: Counts how many errors occurred in a log file.

Advanced Tip: Combine with awk to extract patterns and trends.


10. Quick To-Do List Manager

I like keeping my productivity tools inside the terminal.

#!/bin/bash
todo="$HOME/todo.txt"
case $1 in
  add) echo "$(date +%Y-%m-%d): ${@:2}" >> $todo ;;
  list) cat $todo ;;
  clear) > $todo ;;
  *) echo "Usage: add/list/clear" ;;
esac

Use case: Simple text-based to-do list.


Advanced Tips - Taking Your Scripts Further

Writing scripts is just the beginning. Here’s how I leveled up:

  • Use cron jobs to automate scripts on a schedule.

  • Parameterize scripts so they’re flexible across projects.

  • Add logging to track script activity for debugging.

  • Learn tools like awk, sed, and jq to process data like a pro.

  • Keep scripts in Git to version-control your automation.


Actionable Takeaways

  1. Start small: even a 5-line script can save hours.

  2. Build habits: whenever you repeat a task twice, ask, “Can I automate this?”

  3. Don’t chase perfection: simple scripts are often better than over-engineered ones.

  4. Share your scripts: teammates will thank you for saving them time, too.


Conclusion - Stop Wasting Time, Start Automating

Bash scripting isn’t just for sysadmins. It’s for anyone who values their time. These 10 scripts are ones I’ve personally used to free myself from repetitive tasks and focus on the work that matters.

The best part? Once you start, you’ll see automation opportunities everywhere.

3 views

More from this blog

Code Fusion

58 posts

✍️ Tech writer | 🤖 AI & code explorer | 🔍 Breaking down ML, Blockchain, IoT, Cybersecurity & more into dev-friendly bites. Let’s decode the future, one blog at a time 🚀