How to see junk character in file in.?

Hi

I want to know how to see junk character in a file.
i am not able to see junk character using vi or cat command.
below is the junk char . which i see in host file

 
 10.178.14.67 ac01sp02-vip
 

actually it should be like this

10.178.14.67 ac01sp02-vip

i am using secure CRT tool and change the setting to UTF8 encoding but still i am not able to see junk characters using VI and cat command.

please let me know if there is any command to check this.

for me anything apart from alphabets, number, hyphen sign,
underscore sing, hash sign and dot sign are consider as a junk character

Regards,
Scriptor

Just off to work...
As you do not know what the unicode characters are then see if you can adapt this for your needs:-

Pipe that line through od or hexdump .

in vim you can use "list"

:list

Hi Rudic,

sorry i didn't understand what you mentioned.

can you please elaborate.

thx
Scriptor

However you produce that line, add a pipe symbol and either od (with parameters to modify the result to your satisfaction) or, if available, hexdump (same):

echo '10.178.14.67 ac01sp02-vip' | hd
00000000  31 30 2e 31 37 38 2e 31  34 2e 36 37 e2 96 92 e2  |10.178.14.67....|
00000010  96 92 e2 96 92 20 61 63  30 31 73 70 30 32 2d 76  |..... ac01sp02-v|
00000020  69 70 0a                                          |ip.|
00000023

See those "e2 96 92" repetitions? That's your "junk" chars.

BTW, cat -vet works for me to show them as well.

Hi Rudic,

i want to know how see/check junk character in a /hosts file if present.
as i am not able to see junk character in /hosts file using vi and cat command using secure CTR .

thx
Scriptor

---------- Post updated 12-06-13 at 09:09 AM ---------- Previous update was 12-05-13 at 06:59 PM ----------

Hi Rudic,

also

cat -vet 

not working for me .
it is just adding a dollar sign in the end of the file

10.178.14.67    ac01sp02-vip$

thx

If you cat command accepts -vet with no errors then unprintable characters are not the issue. What locale are you using - please output result of the locale command

Hi Jim

below is the o/p of locale command.

 
 locale
LANG=en_US
LC_COLLATE="en_US"
LC_CTYPE="en_US"
LC_MONETARY="en_US"
LC_NUMERIC="en_US"
LC_TIME="en_US"
LC_MESSAGES="en_US"
LC_ALL=
 

That "junk" is the UTF8 equivalent of the 0x2592 char, a special line drawing char on the apple, possibly a "block" element. And thats what we see three times in the line. Not sure if that makes sense in your /hosts line.

As RudiC has pointed out the characters look like the ancient CGA _Extended_ ROM characters, the UTF8 _equivalent_ of the ROM decimal character 177.

If you consider the string you want to correct as binary rather then pure text then both I and RudiC have pointed you to a method that may work.

As you have no idea without looking at the rawcode in binary format what the character really is then hexdump, od or xxd is really the only quick way to find out...
In this case three binary bytes per character as we are able to detect them through _copy_n_paste_.
Binary bytes E2, 96 and 92 thrice...

Using CygWin...

AMIGA:~> echo -n " 10.178.14.67 ac01sp02-vip" > /tmp/text
AMIGA:~> od -tx1 /tmp/text
0000000 20 31 30 2e 31 37 38 2e 31 34 2e 36 37 e2 96 92
0000020 e2 96 92 e2 96 92 20 61 63 30 31 73 70 30 32 2d
0000040 76 69 70
0000043
AMIGA:~> _

Hi Rudic/Wisecracker,

here my problem is i am not able to see those junk character when i vi or cat host file.

my only concern is how should i see those junk character.
is there any way to see. at present i am using secure CRT tool.

i Googled and found below script that helps in viewing junk character through vi.
but this script is showing the junk character only when viewing the file using latest putty version and not working when do vi in secure crt.

# cat read.sh
  #!/bin/sh
   
  while read N
  do
          if hasjunk "$N"
          then
               echo "$N"
          fi
  done

so here my only concern is to see/figure out junk character in a host file.
thx

---------- Post updated at 09:48 PM ---------- Previous update was at 10:09 AM ----------

looking for help

---------- Post updated 12-12-13 at 08:39 PM ---------- Previous update was 12-11-13 at 09:48 PM ----------

is there any one who can help me
i am really in trouble.