Skip to content

Instantly share code, notes, and snippets.

@the-eric-kwok
Created January 19, 2018 05:45
Show Gist options
  • Save the-eric-kwok/71df28dfd4a8e3dfe3b58eb4eeff2e79 to your computer and use it in GitHub Desktop.
Save the-eric-kwok/71df28dfd4a8e3dfe3b58eb4eeff2e79 to your computer and use it in GitHub Desktop.
convert tabs in text file to spaces
#!/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