convert_txt_unicode

Christians-iMac:convert_txt_unicode chunrix$ cat
DIRNAME_BASENAME_FYI.txt convert_text_unicode.sh
Christians-iMac:convert_txt_unicode chunrix$ cat DIRNAME_BASENAME_FYI.txt
reference to variable of BASENAME,DIRNAME,FULLAPTH.
Christians-iMac:convert_txt_unicode chunrix$ cat convert_text_unicode.sh
#!/bin/bash

#Read the original file.
read -p 'Pls drag the file into terminal: '
#echo the blank row.
echo

#Define 3 variables.
filepath=$(echo $REPLY)
filename=$(basename "$REPLY")
dirname=$(dirname "$REPLY")

#Interaction Area
echo 'U have two options to choose: '
echo '1.gbk to utf8'
echo '2.big5 to utf8'
echo '3.shift-jis to utf8'

#Read the selected number from input, then launch the specified inconv command.
read -p 'Pls input the number you want to launch: '
for i in "$REPLY"
do
[[ "$i" == 1 ]] && iconv -f gbk -t utf8 "$filepath" > "$dirname"/"$filename"_gbk2utf8.txt
[[ "$i" == 2 ]] && iconv -f big5 -t utf8 "$filepath" > "$dirname"/"$filename"_big52utf8.txt
[[ "$i" == 3 ]] && iconv -f shift-jis -t utf8 "$filepath" > "$dirname"/"$filename"_shift-jis2utf8.txt
done

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章