SourceFiles.org - Use the Source, Luke
Home | Register | News | Forums | Guide | MyLinks | Bookmark

Related Sites

Latest News
  General News
  Reviews
  Press Releases
  Software
  Hardware
  Security
  Tutorials
  Off Topic


Back to files

bsed man page

NAME

bsed - binary stream editor

SYNOPSIS

     bsed [-vsw] [-m [min-]max] search=replace infile outfile
     bsed [-vsw] [-m [min-]max] search infile

DESCRIPTION

     bsed searches for a binary string in a file.  If  a  replace
     string  is  given,  bsed copies infile to outfile, replacing
     all instances of the search string with the replace string.
     If infile is '-', input is from standard input;  if  outfile
     is '-', output is to standard output.
     Both the search and the replace strings can contain a combi-
     nation of ascii characters and hex numbers. The following is
     the algorithm used:  If the string begins with a  digit  (0-
     9),  assume  a hex number is beginning.  Continue converting
     hex digits (0-f) into binary until a non-hex  digit  begins,
     unless the string began with "0x" or "0x": in that case just
     throw away the 0x.  Every 2 hex  digits  makes  a  byte;  if
     there  is  an odd number then the last digit is taken as the
     low nibble of a byte.  Anytime a  backslash  ()  is  encoun-
     tered,  consider  it to be a break in the conversion process
     and treat it as  if  starting  a  new  string.   If  another
     backslash  is  immediately following it, insert a backslash.
     Once converting an  ascii  string,  continue  converting  it
     until a backslash or end of string.
     NOTE: be sure to escape the backslash from the shell.

OPTIONS

     -v   verbose option.  First lists the search  (and  replace)
          string in a hex-ascii dump format:  each byte is listed
          first in hex, followed by the ascii for each  printable
          character or "." for each non-printing character.  Next
          it gives a hex-ascii dump of the context of each  match
          of  the  search  string, with the position of the match
          into the file (in hex) in the middle of the dump.  Out-
          put is to stderr.
     -s   Normally bsed  will  list  the  number  of  matches  to
          stderr.  This option suppresses that.
     -w   Normally bsed will  warn  if  the  search  and  replace
          strings   are   not   the  same  length.   This  option
          suppresses that warning.
     -m [min-]max
          Normally bsed will find all the matches of  the  search
          string.  This option specifies a range of match numbers
          to use.  The default mininimum is number 1.   Both  min
          and max are in decimal.

EXAMPLES

bsed -v "ab\0xa" testfile

bsed -sw "data\0=fonts\0" testfile - | od -cx

bsed -v -m5-5 "012345=0xa\bc" testfile testout


Other Sites

Discussion Groups
  Beginners
  Distributions
  Networking / Security
  Software
  PDAs

About | FAQ | Privacy | Awards | Contact
Comments to the webmaster are welcome.
Copyright 2006 Sourcefiles.org All rights reserved.