问题
I have a script contains certain functions/replaces,etc..
But in my output, contains some junks like ^@
.
How to replace this ^@
with a newline? with the script
This command executes in vim commandline %s/<CTRL-2>//g
, but not by script
回答1:
^@
is ASCII 0.
You could use:
sed 's/\x00/\n/g'
回答2:
type command in vim
If you want to fix the result, you could do this in vim:
:%s/
then press:
<Ctrl-V>010
After that your command looks like: :%s/^@
Then you can continue typing:
:%s/^@/\r/g
But I think the better solution is fixing the codes which generated these chars.
in script
If you want to do it in script, there is function : nr2char()
you could do nr2char(10)
to get the ^@
来源:https://stackoverflow.com/questions/34290247/how-to-replace-with-r