Created
March 29, 2025 15:50
-
-
Save YarGnawh/b969b532e3072c9787c7f658275c64ea to your computer and use it in GitHub Desktop.
why touch when you can poke
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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