Skip to content

Instantly share code, notes, and snippets.

@maddisondesigns
Created June 29, 2026 07:49
Show Gist options
  • Select an option

  • Save maddisondesigns/c9314f7e37af0b5e490d252db8c7cdda to your computer and use it in GitHub Desktop.

Select an option

Save maddisondesigns/c9314f7e37af0b5e490d252db8c7cdda to your computer and use it in GitHub Desktop.
MacOS Bash scripts to create new empty file
#!/bin/bash
# Create new empty file
# Exit on any error
set -euo pipefail
# Check for correct usage
if [ $# -lt 1 ]; then
echo "❌ No paramaters specified"
echo "Usage: $0 <newfile.txt>"
exit 1
fi
# Check if files already exists
if test -f "$1"; then
echo "❌ File already exists."
exit 1
fi
touch "$1"
echo "✅ File created: $1"
readlink -f "$1"
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment