Skip to content

Instantly share code, notes, and snippets.

@5HT2
Created September 6, 2021 14:48
Show Gist options
  • Save 5HT2/746386f36ccabf96c794240c422c7d57 to your computer and use it in GitHub Desktop.
Save 5HT2/746386f36ccabf96c794240c422c7d57 to your computer and use it in GitHub Desktop.
#!/bin/bash
# This script runs all .sh files, excluding itself, in the directory it's run in.
# Get name of self script. Only works when running in current dir, doesn't work with symlinks. I'm lazy.
SELF="$(basename "$0")"
for file in *.sh; do
# Check if script is not self, and is a file
if [[ "$file" != "$SELF" ]] && [[ -f "$file" ]]; then
# Check if script is not executable
if ! [[ -f "$file" ]]; then
chmod u+x "$file"
fi
echo "Running script: $file"
./"$file"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment