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:
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
#
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.
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.