Monday, August 13, 2007

Display Non-printable Characters in a Text File

I received a message asking me how to see non-printable characters in a text file. Almost immediately, utilities such as vi, cat, and od come to mind. The od command clearly states which non-printable characters are present. Here are examples using a text file.

# vi filename.txt
^I^I^I^I$
$
$
$
this is a test$
^I^I^I^I$
~
: set list

# cat -vet filename.txt
^I^I^I^I$
$
$
$
this is a test$
^I^I^I^I$

# od -c filename.txt
0000000 \t \t \t \t \n \n \n \n t h i s i s
0000020 a t e s t \n \t \t \t \t \n
0000034

Related post

Using octal dump to find bad characters

1 comment:

Kamlesh said...

i have used the command
cat -vet filename.txt

is showing me ^@ non printable character. So my question is how to remove the same. Please help me out.