Skip to content

Instantly share code, notes, and snippets.

@huevos-y-bacon
Last active March 29, 2022 16:45
Show Gist options
  • Save huevos-y-bacon/ec40c7fc2b5f4e4043d62924a8acb894 to your computer and use it in GitHub Desktop.
Save huevos-y-bacon/ec40c7fc2b5f4e4043d62924a8acb894 to your computer and use it in GitHub Desktop.
Insert lines at top of all files of specified extension
#!/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