Skip to content

Instantly share code, notes, and snippets.

@caruccio
caruccio / bash-path-vars
Last active April 1, 2025 12:54
Path manipulation with bash vars
$ FILE=/some/path/to/file.txt
###################################
### Remove matching suffix pattern
###################################
$ echo ${FILE%.*} # remove ext
/some/path/to/file
$ FILE=/some/path/to/file.txt.jpg.gpg # note various file exts
@joshgachnang
joshgachnang / gist:2306795
Last active April 30, 2024 03:34
Bash Check Username of User Running Script
if [ "$(whoami)" != "username" ]; then
echo "Script must be run as user: username"
exit 255
fi