Skip to content

Instantly share code, notes, and snippets.

@YarGnawh
Created March 29, 2025 15:50
Show Gist options
  • Save YarGnawh/b969b532e3072c9787c7f658275c64ea to your computer and use it in GitHub Desktop.
Save YarGnawh/b969b532e3072c9787c7f658275c64ea to your computer and use it in GitHub Desktop.
why touch when you can poke
#!/bin/bash
# poke - enhanced touch command that creates directories if needed
# Usage: poke file_path
# Installation: Create `poke` file in `/usr/local/bin` and `chmod +x`
if [ $# -eq 0 ]; then
echo "Usage: poke <file_path>"
exit 1
fi
for path in "$@"; do
# Extract the directory part
dir=$(dirname "$path")
# Create the directory if it doesn't exist
if [ "$dir" != "." ]; then
mkdir -p "$dir"
fi
# Create or update the file
touch "$path"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment