Skip to content

Instantly share code, notes, and snippets.

@DewWisp
Created September 1, 2018 01:19
Show Gist options
  • Save DewWisp/0ff2dd6d622e933ad14edf9fef81e4db to your computer and use it in GitHub Desktop.
Save DewWisp/0ff2dd6d622e933ad14edf9fef81e4db to your computer and use it in GitHub Desktop.
ASCII/ANSI -> UTF-8, CR/LF -> LF, Tab -> 4 Spaces, Trim trailing whitespace, Newline at EOF
#!/bin/bash
if [[ $# > 0 ]]; then
for File in $@; do
iconv --to-code=UTF-8 "$File"
sed -i 's/\r$//g' "$File"
expand --initial --tabs=4 "$File"
sed -i 's/[ ]+$//g' "$File"
if [[ $(tail --lines=1 "$File") != "" ]]; then
: >> $File
fi
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment