EXAMPLES - examples of the BSORT command.

bsort file >out

The contents of "file" are sorted in ascending ASCII order and the result is put in "out".

bsort file >out key='il=" "'

This sorts "file" into "out" in ascending ASCII order. Because of the "IgnoreLeading=" field, the sort will ignore any leading blanks that appear at the beginning of each line.

bsort file key="fr=41,b=48,+des,+num" key="fr=0,b=30"

"file" is sorted according to two keys. The first key is numeric; it begins after character 41 and ends at character 48 (the initial character of the record is character 0). The records are sorted according to this key in descending (+des) numeric (+num) order.

Records which have the same first key are sorted according to a second key. This key begins with the initial character of the record and ends at character 30.

bsort file key='f=2,stop=":"' key='f=1,stop=":"'

Another sort with two keys. The fields in the record are delimited by colons. The first key is the second field, beginning after the first colon. The second key is the first field, beginning at the start of the record.

bsort file stop=":" key=f=2 key=f=1

This is identical to the previous sort.

bsort file -dup key=fr=0,len=2bits

The file is sorted on the first two bits of every record. Records which have the same two bits as previous records will be discarded because of the -Duplicate option. Thus the output will have a maximum of four records. If you simply want to eliminate duplicate records (as opposed to records with duplicate keys), put the option

key=

as the final key on the command line. Due to the defaults, the sort will take the entire record as a second key, and will only discard records which duplicate each other in their entirety.

bsort bcdfil >bcdfil

This reads in a BCD file and writes the sorted result into the same file. Because of the defaults +Raw and +AscII, the input will be sorted as if it consists of unsigned integers. This means that the BCD data will actually be sorted into BCD collating order.

bsort -raw bcdfil >bcdfil mc=2

This reads in BCD data and converts it internally to ASCII. The sort will therefore be done in ASCII collating order. The result is written out in BCD because of the MediaCode=2.

bsort file key="f=3,st=' ',sk=' ',+loc"

This sorts on the location of the third field in the record. Since fields are delimited by spaces, the result is output giving records whose third word appears later and later in the line.

See Also:

expl bsort
full description of BSORT
expl bsort batch
using BSORT in batch
expl bsort collate
collating orders
expl bsort errors
error handling
expl bsort keyopt
key options
expl bsort notes
miscellaneous notes
expl bsort options
general command line options
expl bsort position
key position descriptors

Copyright © 1996, Thinkage Ltd.