xtsort

Section: User Commands (1)
Updated: 2002-10-26
Index Return to Main Contents

 

NAME

xtsort - sort records

 

SYNOPSIS

xtsort -k key attribute(s)[%{n|r}] [-i INPUT] [-o OUTPUT] [-z] [-t] [-T TEMP DIRECTORY]

 

DESCRIPTION

This command rearrange the records according to the key -k irrespective of the sort order information stored in the header. The sort order on attribute can either be in numerical order or character order and by ascending or descending order. The ordering options are listed as follows:
  %r : descending order
  %n : numerical order For example, for the file with two attributes 'customer' and 'amount',
  -k customer,amount :
    rearranges the file in the character and ascending order.
  -k customer,amount%n
    'customer' is sorted in character order and ascending order; 
    'amount' is sorted in numerical and ascending order. 
  -k customer,amount%nr :
    'customer' is sorted in character order and ascending order;
    'amount' is sorted in numerical and nonincreasing order.
  -k customer%r,amount%nr
    'customer' is sorted in the character order and nonincreasing order;
    'amount' is sorted in numerical and nondecreasing order.

 

PARAMETERS

-k key attribute(s)
key attributes where sorting will be based on.
-T temp directory
specify the directory name for temporal files used in this command.

 

FILE OPTIONS

-i input filename
if a suffix of the filename is '.gz', the command acts as a filter, extracting t he compressed file for processing. The command will read the file as standard in put when "-i" is not specified.
-o output filename
if a suffix of the filename is '.gz', the command automatically returns the outp ut data in zip archive. When "-o" is not specified, the result will sent to stan dard output.
-z zip archive
compress the standard output to zip archive. When the option "-o" is not given a nd "-z" is specified, the output will be compressed as zip archive.
-t plain text
treats the input and output data as plain text format.

 

USAGE

Input file - dat.xt:
<field no="1">
<name>CustomerID</name>
</field>
<field no="2">
<name>Date</name>
</field>
<field no="3">
<name>TotalAmount</name>
</field>
<field no="4">
<name>TotalQuantity</name>
</field>
<body><![CDATA[
A00004 20020214 1 365
A00004 20020214 1 565
A00004 20020415 9 4349
A00004 20020214 3 650
A00005 20020928 12 4554
A00005 20020928 12 505
A00005 20020923 1 491
A00056 20021128 1 94
A00056 20021128 1 112
A00056 20021128 1 115
A00056 20021128 1 93
A00056 20021128 1 149
]]></body>
  Example 1. Sort the records by customer and date purchased. e.g. xtsort -k CustomerID,Date -i dat.xt -o rsl.xt Output file -rsl.xt
<body><![CDATA[
A00004 20020214 1 365
A00004 20020214 1 565
A00004 20020214 3 650
A00004 20020415 9 4349
A00005 20020923 1 491
A00005 20020928 12 4554
A00005 20020928 12 505
A00056 20021128 1 112
A00056 20021128 1 115
A00056 20021128 1 149
A00056 20021128 1 93
A00056 20021128 1 94
]]></body>

Example 2. Sort the records by Customer and total amount purchased in numerical order. e.g. xtsort -k CustomerID,TotalAmount%n -i dat.xt -o rsl.xt Output file -rsl.xt

<body><![CDATA[
A00004 20020214 1 365
A00004 20020214 1 565
A00004 20020214 3 650
A00004 20020415 9 4349
A00005 20020923 1 491
A00005 20020928 12 4554
A00005 20020928 12 505
A00056 20021128 1 94
A00056 20021128 1 112
A00056 20021128 1 115
A00056 20021128 1 93
A00056 20021128 1 149
]]></body>

Example 3. Sort the records by Customer and total amount in numerical descending order. e.g. xtsort -k CustomerID,TotalAmount%nr -i dat.xt -o rsl.xt Output file -rsl.xt

<body><![CDATA[
A00004 20020415 9 4349
A00004 20020214 3 650
A00004 20020214 1 365
A00004 20020214 1 565
A00005 20020928 12 4554
A00005 20020928 12 505
A00005 20020923 1 491
A00056 20021128 1 94
A00056 20021128 1 112
A00056 20021128 1 115
A00056 20021128 1 93
A00056 20021128 1 149
]]></body>

 

SEE ALSO

For complete documentation and tutorial of xtsort and other commands, please visit http://musashien.sourceforge.net

 

BUG REPORT

If you find a bug in xtsort, please send an electronic mail to musashi@adm.osaka-sandai.ac.jp. Before sending a bug report, please verify that you have the lastest version of MUSASHI. Read this manual carefully to ensure the error is not caused by a quirk in the language.

 

AUTHORS

Yukinobu Hamuro, Naoki Katoh, Katsutoshi Yada, Stephane Cheung


 

Index

NAME
SYNOPSIS
DESCRIPTION
PARAMETERS
FILE OPTIONS
USAGE
SEE ALSO
BUG REPORT
AUTHORS

This document was created by man2html, using the manual pages.
Time: 22:43:56 GMT, June 24, 2003