regex to remove strange character from text file

Each line of text in log file I get from a device has a small rectangle at the begining, how do I get rid of it? Here is what it looks like, just imagine the zero's are small rectangles:

0SeqNum: 57
0Display: 1
0Point: 9
0CurrentState: Alarm

I have chomped, choped, tried to strip out with regexs, and have had no success.
omcrAsked:
Who is Participating?
 
ozoCommented:
#!/usr/bin/perl
{local @ARGV=<*.log>;
 local $I^='';
 while( <> ){
    s/\xd//g;
    print;
 }
}
0
 
ozoCommented:
what do you see if you do
while( <> ){
  s/([^\n -z])/sprintf'\x%02x',ord $1/eg;
  print;
}
0
 
omcrAuthor Commented:
That gave me this:
\x0dSeqNum: 81\x0d
\x0dDisplay: 1\x0d
\x0dPoint: 9\x0d
\x0dCurrentState: Alarm\x0d
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
ozoCommented:
"\0xd" is a carriage return, was the log file generated in DOS?
perl -i.bak -pe 's/\xd//g' logfile
0
 
omcrAuthor Commented:
generated in unix.
Can you put "perl -i.bak -pe 's/\xd//g' logfile" into a file format instead of command line?
0
 
Kim RyanIT ConsultantCommented:
Can you dump the file so we can identify the strange character?
od -s logfile
od -x logfile

If you are on unix, thr tr utility may be simpler. The first example removes all control characters. The second, all characters with octal value of 015

cat logfile | tr -d '[:control:]' > new_logfile
cat logfile | tr -d '\015' > new_logfile
0
 
omcrAuthor Commented:
That did it. Thanks.
0
 
omcrAuthor Commented:
Did not see your post before I commented last time teraplane, but ozo's suggestion cleaned it up, and my scripts are now working. Thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.