able to remove \240 from a text file

I have a file originally provided from a SQL database on a Windows platform.

I transfer the file via ftp in binary format, remove the ^M's from the end of all lines.

I have attempted to use tr ( cat infile | tr -d '\240' ) and sed (cat infile | sed 's/\240//g' ) to remove the occurences of \240 in the file with no luck.

I have no problem removing this octal character in vi.

If i run the Windows command, 'type infile', \240 shows up as an a with a grave over it.

In notepad, it shows up as a space.

I need to incorporate into a script a method of deleting these octal characters because other unix commands fail w/ the following error:

can't read STDIN: Illegal byte sequence

Any ideas would be greatly appreciated.

Thx in advance,

pat

 sed 's/\\240//g' file 

tried this - it did not find and replace the \240

there was no change after running this command

pat

Hi,

try

sed 's/\o240//g' file

HTH Chris

tried

sed 's/\o240//g' file

no luck - didn't know if this was o240 or 0240 so i tried both to no avail

thx

pat

What do you mean "there was no change"? No change in the output or no change in the file? The sed command doesn't edit the file,m just display changes to standard output. You need to redirect the output to another file, or of you have gsed, I believe there is a -e flag that will actually edit the file.

# cat file
 hello \240 world \240hello\240world

# sed 's/\\240//g' file
 hello  world helloworld
# 

system shock,

i ran your command and redirected the output to another file:

sed 's/\\240//g' file > output_file

the output_file still has the \240 characters in it.

sorry to be vague.

pat

This should work, but check the syntax of "echo" on your unix.

#!/bin/ksh
BADCHAR=`echo "\0240"`
cat infile|tr -d "${BADCHAR}"

methyl,

so i used your shell program and just added a redirect to a file like so:

cat infile|tr -d "${BADCHAR}" > outfile

when i looked at the outfile w/ vi the \240 chars were still there but with a trailing \256 on the first occurence of the \240 and a trailing \211 after the second \240

the line in vi looks like this: MACHINENAME\240\256.com MACHINENAME\240\211.com

before running your script, the line looked like:

MACHINENAME\240\.com MACHINENAME\240\.com

BTW the \240, \256 and \211 characters are one character - like an embedded control character.

weird

thx for trying,

pat

sed l file

The sed command "l" (a small L) will print out
all non-printable characters in escaped form.
Then run sed again with the escape sequence for
your non-printable character.

it just came back showing me \240 as the unprintable character - not sure how i can use this another way.

I have the same problem with the \240 character. This works for me:

tr '\240' ' ' < infile > outfile

Note that there is a "space" between the two ' ' marks.