Re: Replacing characters in file



In article <%7iOh.1641$Rp2.877@trndny04>, "Jürgen Exner"
<jurgenex@xxxxxxxxxxx> wrote:

Anony-mouse wrote:
In article <Z9aOh.3620$J21.675@trndny03>, "Jürgen Exner"
If on the other hand you don't have a text file, then maybe it is
time to stop treating it as a text file but start handling it as a
binary file instead.

It's not a text file. As I said it's a .DAT file

Whatever that is supposed to mean.
A file name ending of .DAT doesn't imply anything as to the content of the
file.

Although not necessarily true, it does imply that it's not a simple
..TXT file.



that contains control
characters, including EOF ones. :o\

Well, if it is not a text file but a binary file, then it isn't very
meaningful to talk about characters.
It would have been much less confusing if you had said "I have a two-byte
sequence"01 5F" (denoted in hex) and like to replace it with "01 5C".

Symantics (or pendaticism, whichever you prefer). It still means the
same thing and some people seem to have understood what I was saying,
while others simply want to get picky about terminology.



I still don't understand why a simply
s/\x01\x5F/\x01\x5C/g
shouldn't work.

It doesn't work in SED because SED aborts when it hits the first EOF
character and so doesn't complete the file.

In the version of Perl I've been using it simply does nothing - I get a
completely empty result file. I'll have to wait until I finish
downloading Active Perl and see what happens there, but that may be too
big in filesize for my needs.


_
_/ \___
Anony-mouse says o_/O _/ \
"Eek-eek-eek!" \__/_|_/_|\____/
.



Relevant Pages

  • Re: fseek
    ... >>a text stream to a binary file or vice versa. ... >>binary file in text mode or vice versa results in undefined behavior. ... newline characters are treated the same as ... On IBM's mainframe OSs lines never have newline characters on them, ...
    (comp.lang.c)
  • Re: Replacing characters in file
    ... Well, if it is not a text file but a binary file, then it isn't very ... meaningful to talk about characters. ... Computers are notorious at being extremely pedantic. ... It doesn't work in SED because SED aborts when it hits the first EOF ...
    (comp.lang.perl.misc)
  • Re: Delete key leaves ghost characters at command prompt in xterm
    ... incorrect characters, and output characters to be garbled. ... remember how xterm behaved in those circumstances. ... But I am wondering if I might have cat a binary file by ... page (the pager used by man usually is configured to reset the display ...
    (comp.os.linux.misc)
  • Re: replacing text data in a binary file
    ... &HFF for the byte. ... That explains the cbyte in ... >> If you are editing a binary file I would recommend opening the file with ... >> removing or adding characters may actually corrupt the file, ...
    (microsoft.public.dotnet.languages.vb)