I want to replace a string "/usr/local" with another string "/tmp/local" in a binary file.
This is what I wrote: #!/usr/local/bin/perl $file = "./mybinaryfile.out"; $s1 = `strings $file | grep -b /usr/local`; # returned 2027:/usr/local/conf/ ($byteoffset, $string) = split /:/, $s1; $slen = length($string); # returned 16 open IN, $file or die "Can't open $file for reading: $!\n"; seek IN, $byteoffset, 0; read IN, $rstr, $slen; print "$rstr \n"; What I expected to see was $rstr equal to $string, but instead I got a bunch of binary characters. Does "grep -b" return the wrong byteoffset? Eventually, after I get past this problem, I'm going to modify the string and write it back. Since the length of the modified string is the same as the original, it shouldn't hurt/break the binary file. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]