Bash Scripting Sunday #5: Safely Working with Temporary Files in Bash

This week in Bash Scripting Sunday, we’re diving into a small topic with a big impact: handling temporary files safely and securely. Temporary files are common in scripting — for holding intermediate data, logs, or scratch work. But if you’re using something like: tmpfile="/tmp/myscript.tmp" …you might be exposing yourself to race conditions, file collisions, or even security issues. Let’s fix that. 🛠️ 🧪 The Problem with Hardcoded Temp Files Hardcoding paths like /tmp/foo.txt can lead to problems: ...

April 6, 2025 · 2 min · MeaTLoTioN

Bash Scripting Sunday #4: Creating a Simple Interactive Menu in Bash

In this week’s Bash Scripting Sunday, we’re diving into creating simple interactive menus in Bash. If you’ve ever wanted to give your scripts a bit of user interactivity—like choosing from a list of options—you’ll love this one. 🧭 Why Use Menus? Menus are great when: You want to prompt the user for input from a list You’re writing utility scripts with multiple actions You want something more user-friendly than raw read input 🔧 The Basics: select and PS3 Bash comes with a built-in construct called select that makes menus easy. ...

March 30, 2025 · 3 min · MeaTLoTioN

Bash Scripting Sunday #3: Using xargs Effectively – More Than Just a Pipe

When dealing with large lists of files or data in Bash, it’s tempting to throw everything into a loop or use while read pipelines. But there’s a better tool that often gets overlooked: xargs. In this week’s Bash Scripting Sunday, let’s dive into how to use xargs more effectively – and why it’s so much more than just a glorified pipe. 🧠 What is xargs? xargs takes input from stdin and converts it into arguments for a command. ...

March 23, 2025 · 3 min · MeaTLoTioN

Bash Scripting Sunday #2: Writing a Safe and Robust Bash Script

Bash Scripting Sunday #2: Writing a Safe and Robust Bash Script In today’s post, I’d like to give some insight into writing safer scripts using Bash’s built-in options. Why Script Safety Matters A poorly written script can cause unintended data loss, infinite loops, or security vulnerabilities. Writing robust scripts ensures they behave predictably and handle errors gracefully. 1. Enabling Safe Bash Options Bash provides built-in options to catch errors early and prevent common pitfalls. ...

March 16, 2025 · 2 min · MeaTLoTioN

Bash Scripting Sunday #1: Bash Parameter Expansion - Save Time and Avoid Subshells

Bash Scripting Sunday #1: Bash Parameter Expansion - Save Time and Avoid Subshells In this entry, I’d like to show you how to use Bash Parameter Expansion to make your life a little easier, your scripts a little quicker, and use less resources. Here’s an example script that isn’t using Bash Parameter Expansion: #!/usr/bin/env bash filename="/path/to/file.txt" echo "Basename: $(basename $filename)" # file.txt echo "Dirname: $(dirname $filename)" # /path/to This script will output: ...

March 9, 2025 · 3 min · MeaTLoTioN