14 lines
537 B
Bash
Executable File
14 lines
537 B
Bash
Executable File
#!/bin/sh
|
|
|
|
if [ -z "$1" ] || [ "$1" = '-h' ] || [ "$1" = '--help' ] || [ "$1" = 'help' ]; then
|
|
FILENAME=$(basename "$0")
|
|
printf "$FILENAME : tool to easily convert file to UTF-8 encoding.
|
|
Created by Pierre Saunders @saundersp 2021\n\nUsage:
|
|
\t$FILENAME filename.txt\n\tConvert filename.txt to UTF-8 encoding.
|
|
\n\t$FILENAME\n\t$FILENAME help\n\t$FILENAME --help\n\t$FILENAME -h
|
|
\tDisplay this usage message.\n"
|
|
else
|
|
TMP_FILE=$(mktemp)
|
|
iconv -f "$(file -i "$1" | cut -d = -f 2)" -t "UTF-8" "$1" > "$TMP_FILE" && mv "$TMP_FILE" "$1"
|
|
fi
|