try iconv -f UTF16 -t UTF8 <your-file> > <new-file>
Remove ^@ characters from linux file
题
I have a file which has visible ^@
characters (blue) after each character. I can see these characters only in vi file.txt
. I am unable to view these characters using cat
. How can I remove them?
I tried using the following command:
sed "s/[^@]//g" a.txt > b.txt
However this didn't seem to alter the file.
解决方案
其他提示
dos2unix file.txt file.txt
. This will do..
This works:
sed "s/[\^@]//g" a.txt > b.txt
I remove all files in dir with inappropriate symbols in a such way:
for i in *.*;do
case "$i" in
*[\(\)\!\*\%\^\ ]*)
mv "$i" ${i//[^a-zA-Z0-9.]/_}
;;
esac
done
[()!*%^\ ] -- stands for eliminate any symbol from the set of: ()!*%^ and space [^a-zA-Z0-9.] -- stands for not English low and upper cases charecters, numbers and dots
What is important it only renames files containing 'bad' characters.
不隶属于 StackOverflow