how can I use linux command sed to process Little-endian UTF-16 file
endianness, shell, utf-16
Solution
If the file is UTF-16 encoded text (as RDP is), and that is not your current encoding (it's not likely to be on Linux) then you can pre- and post-process the file with `iconv`. For example:
iconv -f utf-16 -t us-ascii <rdpzhitong.rdp |
sed 's/original/modified/' |
iconv -f us-ascii -t utf-16 >rdpzhitong.rdp.modified
Problem
I am working on an application about windows rdp. Now I get a problem when I try to use the sed command to replace the string of IP address directly in the rdp file. But after executing this command, the origin rdp file is garbled. ``` sed -i "s/address:s:.*/address:s:$(cat check-free-ip.to.rdpzhitong.rdp)/" rdpzhitong.rdp ``` I find that the file's format is Little-endian UTF-16 Unicode. Can I still use the sed command to replace the text in the files correctly? Or other method to process this problem?