I am very new to shell scripting and having issue replacing character of tab delimited csv.
I want to convert the csv to text file and change the delimiter from tab to ~ , i tried below code but the delimiter turns out different some like japanese char " instead of ~.
sed 's/\t/\"\~\"/g' test.csv > test.txt
Appreciate your help.. thanks in advance
CodePudding user response:
If it's char for char, use tr:
cat test.csv | tr '\t' '~' > test.txt
CodePudding user response:
Use iconv to change encoding to UTF-8:
iconv -f utf-16 -t utf-8 < test.csv | sed 's/\t/"~"/g' > test.txt
" and ~ can go unescaped.
