我有一个关于删除不可见字符的问题,只有当我们尝试使用vi命令查看文件时才能看到。我们有一个由Datastage Application生成的文件(Source是一个DB2表 - > Target是一个.txt文件)。文件具有不同数据类型的数据。我遇到一个问题,只有3列,其数据类型定义为CHAR。
I have a question about removing invisible characters which can be only be seen when we try to view the file using "vi" command. We have a file that's being generated by Datastage Application (Source is a DB2 Table -> Target is a .txt File). File has data with different data types. I'm having an issue with just 3 columns which have their datatypes defined as CHAR.
如果你打开文本文件夹中的文件,你会看到空格。但是当你通过vi命令在Unix上查看同一个文件时,我们看到^ @字符为蓝色。我的文件是一个分隔符文件,分隔符为^ @ ^(我知道它有点听起来很奇怪)。
If you open the the file in a Textpad you'd see spaces. But when you view the same file on Unix via vi command, we see ^@ characters in blue color. My file is a delimiter file with the delimiter as ^@^ (I know it's kinda sounds weird) .
我试过:
真的很感激。我研究了这个网站上的帖子,但我找不到一个。
Any suggestions are really appreciated. I have researched the posts on this website but I couldn't find one. If it's a simple please excuse me and share your thoughts.
推荐答案在 vi 中,NUL个字符表示为 ^ @ 。要清除它们:
In vi, NUL characters are represented as ^@. To get rid of them:
使用 tr 能够删除NUL字符,如下所示:
Using tr, you should be able to remove the NUL characters as follows:
tr -d '\000' < file-name > new-file-name更多推荐
删除^ @ Unix文件中的字符
发布评论