Example 1: Comparing Two Files

fb h File1 File2

      8514:  5 FD
     41145: D1  0
     41146:  A 6E
    598002: 9A B3
    598818:  EOF  :1902318

The output reports the offsets where the two files differ and their differences in hexadecimal. Since the files differ in length, the last line of the output reports their respective file lengths.

For Linux/UNIX users: "fb o File1 File2" is similar to "cmp -l File1 File2"; however, be aware that cmp starts counting bytes from 1 rather than 0 as fb and od do. Also "fb . File1 File2" is similar to "cmp -s File1 File2".


Example 2: Searching with grep

fb -blnks -p 1 -i 6 File | grep 1100000011

will find occurances of the bit pattern 1100000011. Explanation: (1) "-b" will (by default) show 8 bytes per row. (2) The bit pattern 1100000011 could span 3 bytes. (3) Thus the increment must be 6 ("-i 6") in order not to miss cases where the 3 bytes start in one row but end in the next row.


Example 3: Removing Carriage Returns from DOS Files

Linux/UNIX:

fb -lans File.txt | sed s/0D//g | fb th File.unx

Windows 95, 98, & NT:

(1) fb -lans File.txt > File.unx

(2) Edit File.unx so as to remove all occurances of " 0D".

(3) fb t h File.unx

The new file, File.unx, will have no carriage returns.

For Linux/UNIX users: fb will also translate dumps made with od since when fb reads hexadecimal numbers it is not sensitive to case. "fb -lans File" is similar to "od -An -v -tx1 File"; "fb -lands File" is similar to "od -An -v -tu1 File"; and "fb -loans File" is similar to "od -An -v -to1 File". All of these outputs can be translated by fb; but, in addition, fb can translate a file of the format produced by "fb -blans File", which is a dump in binary numbers. And fb can translate a file wherein the numbers are not delimited (or there is a mixure of some delimited and some not). Adding the -k option to any of the fb examples above will result in the dump having no spaces between numbers.


Example 4: Browsing Small Files

If a file is less than 256 bytes (or less than 128 bytes with the -b option or less than 1024 bytes with the -c option), use the -p option. For example suppose File is 123 bytes in size. One way to browse this file is to start fb like so:

fb -p 10.10 -i 23 File

This will display the first 100 bytes of the file. To view the remaining 23 bytes simply press ENTER. This will display the last 100 bytes of the file. Then enter the command "-" to alternate between the first and last 100 bytes of the file.

Example 5: Deleting a Portion of a File

Use the script delete (see below under Linux/UNIX) or the batch file delete.bat (see below under Windows 95, 98, & NT) like so:

delete Offset1 Offset2 File1 File2

to delete bytes starting at Offset1 and stopping at Offset2 from file File1, writing the result to File2. File1 is not changed.

For example to delete 100 bytes from File1 starting at offset position 1000, writing the result to File2, execute the command:

delete 1000 1100 File1 File2

Linux/UNIX:

#!/bin/bash
# delete
fb c .$1 $3 $4
fb a $2 $3 $4

Windows 95, 98, & NT:

@echo off
rem delete.bat
fb c .%1 %3 %4
fb a %2 %3 %4

Note: adding a usage statement and error checking to either the script or batch file is left as an exercise.


Example 6: Inserting a File Into Itself or Another File

Use the script insert (see below under Linux/UNIX) or the batch file insert.bat (see below under Windows 95, 98, & NT) like so:

insert File1 Offset File1|File2 File3

to insert File1 into either File1 or File2 at offset position Offset and write the result to File3. File1 and optional File2 are not changed.

For example to insert File1 into File2 at offset position 1000, writing the result to File3, execute the command:

insert File1 1000 File2 File3

Linux/UNIX:

#!/bin/bash
# insert
fb c .$2 $3 $4
fb a . $1 $4
fb a $2 $3 $4

Windows 95, 98, & NT:

@echo off
rem insert.bat
fb c .%2 %3 %4
fb a . %1 %4
fb a %2 %3 %4

Note: adding a usage statement and error checking to either the script or batch file is left as an exercise.


Example 7: Creating/Editing a Bit Map File Using Translate

The following are the contents of the description file net.fbb and the Windows bit-map file net.bmp created when fb translates net.fbb. To do this fb is invoked like so:

fb t b net.fbb net.bmp

- or -

fb tb net.bmp < net.fbb

The file net.fbb:

| net.fbb
| Author: John Swaby
|   Date: 17 October 1998

| This file should be translated by fb t b(inary)

| Header information:
 | Type of file
  01000010 01001101 | BM (Bit Map)

 | Size of file: 190
 |     190 +  256*0 + 65535*0 + 16777200*0
  10111110 00000000  00000000     00000000

  00000000 00000000 00000000 00000000

 | Length of header: 62
  00111110 00000000 00000000 00000000

  00101000 00000000 00000000 00000000 | 40 0 0 0
  00100000 00000000 00000000 00000000 | 32 0 0 0
  00100000 00000000 00000000 00000000 | 32 0 0 0
  00000001 00000000 00000001 00000000 |  1 0 1 0
  00000000 00000000 00000000 00000000
  10000000 00000000 00000000 00000000 | 128  0 0 0
  00010011 00001011 00000000 00000000 |  19 11 0 0
  00010011 00001011 00000000 00000000 |  19 11 0 0
  00000010 00000000 00000000 00000000 |   2  0 0 0
  00000010 00000000 00000000 00000000 |   2  0 0 0

 | Background color (0's):
 |Blue: 64 Green:64 Red: 0   Unused
  01000000 01000000 00000000 00000000

 | Foreground color (1's):
 |Blue:160 Green:150 Red: 0   Unused
  10100000 10010110  00000000 00000000

| Bit map:
01111111111111000011111111111110
10111111111111000011111111111101
11011111111111111111111111111011
11101111111111111111111111110111
11110111111111111111111111101111
11111011111111111111111111011111
11111101111111111111111110111111
11111110111111111111111101111111
11111111100000000000000111111111
11111111010000000000001011111111
11111111001000000000010011111111
11111111000100000000100011111111
11111111000010000001000011111111
11111111000001000010000011111111
00111111000000111100000011111100
00111111000000111100000011111100
00111111000000111100000011111100
00111111000000111100000011111100
11111111000001000010000011111111
11111111000010000001000011111111
11111111000100000000100011111111
11111111001000000000010011111111
11111111010000000000001011111111
11111111100000000000000111111111
11111110111111111111111101111111
11111101111111111111111110111111
11111011111111111111111111011111
11110111111111111111111111101111
11101111111111111111111111110111
11011111111111111111111111111011
10111111111111000011111111111101
01111111111111000011111111111110
| end of file: net.fbb

The file net.bmp in two parts: header and bit map.

The header: fb -dn -r .62 -p .6 net.bmp

   [  0   1   2   3   4   5]
00: 066 077 190 000 000 000
06: 000 000 000 000 062 000
12: 000 000 040 000 000 000
18: 032 000 000 000 032 000
24: 000 000 001 000 001 000
30: 000 000 000 000 128 000
36: 000 000 019 011 000 000
42: 019 011 000 000 002 000
48: 000 000 002 000 000 000
54: 064 064 000 000 160 150
60: 000 000

The bit map: fb -blnks -p .4 -r 62 net.bmp

062:01111111111111000011111111111110
066:10111111111111000011111111111101
070:11011111111111111111111111111011
074:11101111111111111111111111110111
078:11110111111111111111111111101111
082:11111011111111111111111111011111
086:11111101111111111111111110111111
090:11111110111111111111111101111111
094:11111111100000000000000111111111
098:11111111010000000000001011111111
102:11111111001000000000010011111111
106:11111111000100000000100011111111
110:11111111000010000001000011111111
114:11111111000001000010000011111111
118:00111111000000111100000011111100
122:00111111000000111100000011111100
126:00111111000000111100000011111100
130:00111111000000111100000011111100
134:11111111000001000010000011111111
138:11111111000010000001000011111111
142:11111111000100000000100011111111
146:11111111001000000000010011111111
150:11111111010000000000001011111111
154:11111111100000000000000111111111
158:11111110111111111111111101111111
162:11111101111111111111111110111111
166:11111011111111111111111111011111
170:11110111111111111111111111101111
174:11101111111111111111111111110111
178:11011111111111111111111111111011
182:10111111111111000011111111111101
186:01111111111111000011111111111110