Created
January 19, 2018 05:45
-
-
Save the-eric-kwok/71df28dfd4a8e3dfe3b58eb4eeff2e79 to your computer and use it in GitHub Desktop.
convert tabs in text file to spaces
This file contains 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 | |
# Set the count of space to 2 | |
SPACES=" " | |
if [ "$1" == "--help" ]||[ "$1" == "-h" ]||[ -z "$1" ]; then | |
echo "Function: Transform tabs to spaces." | |
echo "Usage: tab2space [file]" | |
exit 1 | |
fi | |
sed "s|\t|$SPACES|g" "$1" > "$1.new" | |
mv "$1.new" "$1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment