Created
February 23, 2026 17:24
-
-
Save LightningStalker/ad68eac5d9692d603a9149c2a337a56d to your computer and use it in GitHub Desktop.
wa.sh : remove the trailing whitespace
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 | |
| # wa.sh - rinse away the sin of trailing whitespace <- Project Crew™ 2/23/2026 | |
| PROGNAME=$(basename ${0}) | |
| if test -n "${1}" | |
| then | |
| if test -f "${1}" | |
| then | |
| NL=$(egrep -ch ' +$' ${1}) | |
| echo ${PROGNAME}: Found ${NL} line\(s\) ending in whitespace. | |
| if test ${NL} -gt 0 | |
| then | |
| echo ${PROGNAME}: Cleaning it up... | |
| sed -i -r 's/ +$//' ${1} | |
| else | |
| echo ${PROGNAME}: Nothing to do. | |
| fi | |
| else | |
| echo ${PROGNAME}: \'${1}\': File not found | |
| fi | |
| else | |
| echo "${PROGNAME}: I can remove the trailing whitespace. Name a file." | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment