Last active
August 7, 2024 10:40
-
-
Save huevos-y-bacon/ec40c7fc2b5f4e4043d62924a8acb894 to your computer and use it in GitHub Desktop.
Bash - Insert lines at top of all files of specified extension
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
#!/usr/bin/env bash | |
# Insert lines at the top of a file | |
ext=sh | |
for f in *.${ext}; do | |
# e.g. add shebang and shellcheck disable | |
printf '%s\n%s\n' "#shellcheck disable=1072,1073,1035,1020" "$(cat ${f})" >${f} | |
printf '%s\n%s\n' "#\!/usr/bin/env bash" "$(cat ${f})" >${f} | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment