Created
June 29, 2026 07:49
-
-
Save maddisondesigns/c9314f7e37af0b5e490d252db8c7cdda to your computer and use it in GitHub Desktop.
MacOS Bash scripts to create new empty file
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 | |
| # 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