SUNSORT Examples


Example 1:

SUNSORT MYFILE -1-5

 

Sorts the data in 'MYFILE.TXT' in ascending sequence based on the data in record positions 1 to 5.

Example 2:

SUNSORT -IC:\TEMP\SUNSORT.INI MYFILE D,1-5

 

Sorts the data in 'MYFILE.TXT' in descending sequence based on the data in record positions 1 to 5. Utility keywords are first retrieved from the SUNSORT.INI file in the C:\TEMP directory.

Example 3:

SUNSORT MYFILE,SORTED -D,1-3,7-9,11-12,20-25

 

Sorts the data in 'MYFILE.TXT' into 'SORTED.TXT' with record positions 1 to 3, 7 to 9, 11 to 12, and 20 to 25 being sorted in descending sequence.

Example 4:

SUNSORT MYFILE,SORTED -U,D1-3,7-9,A11-12,20-25

 

Sorts the data in 'MYFILE.TXT' into 'SORTED.TXT' with record positions 1 to 3 and 7 to 9 being sorted in descending sequence while 11 to 12 and 20 to 25 are sorted in ascending sequence. All lower case characters are sorted as if they were upper case.

Example 5:

SUNSORT MYFILE,SORTED -1-3,D,7-9,A,11-12,20-25

 

Sorts the data in 'MYFILE.TXT' into 'SORTED.TXT' with record positions 1 to 3, 11 to 12, and 20 to 25 being sorted in ascending sequence while record positions 7 to 9 are sorted in descending sequence.

 

Example 6:

sunsort input.txt output.txt -1-5,r#1-15,' ABC ',16-50# MS-DOS

sunsort input.txt output.txt -1-5,r#1-15,\' ABC \',16-50# Linux

 

This sort command sorts the input file on columns one to five. Each record being written to the output would have the characters " ABC " added between columns 15 and 16. The output record size would be 55 bytes.

 

Example 7:

sunsort input.txt output.txt -150,r\"20-35,1-19,36-100\"

 

This sort command rearranges the columns for records written into the output file. Assuming that the input file had 100 bytes per record, no data would be lost or added.

Example 8:

sunsort oldfile.txt newfile.txt -1-7,r\"1-44,'New Field',45-100\" MS-DOS

sunsort oldfile.txt newfile.txt -1-7,r\"1-44,\'New Field\',45-100\" Linux

 

This example assumes oldfile.txt had a record length of 100. The output newfile.txt will have a record length of 109, and the string 'New Field' will be insert after byte position 44 in each record. The \" form of the delimiter is used as some operating systems strip off the quote character in the command line processing. The \ is a forcing character that leaves the " in the command line.

 

Example 9:

sunsort oldfile.txt newfile.txt -1-7,r#\"1-44,' ',45-100\"# MS-DOS

sunsort oldfile.txt newfile.txt -1-7,r#\"1-44,\' \',45-100\"# Linux

 

This example generates the same record length as before, but the inserted characters are spaces instead of 'New Field'. Since spaces are being inserted, you must use the quotes inside the specification string in order to keep all of the spaces. If the quotes were not present, then only one space would be inserted into the record and the new record length would only be 101 instead of 109.

 

Example 10:

sunsort oldfile.txt report.txt -1-7,r#1-7,' ',8-38,' (',45-47,') ',48-50,'-',51-54# MS-DOS

sunsort oldfile.txt report.txt -1-7,r#1-7,\' \',8-38,\' (\',45-47,\') \',48-50,\'-\',51-54# Linux

 

This example generates a report file with formatting information placed in it. Assuming 1-7 was account number, 8-38 was name and 45-54 was a phone number, it would generate a quick file that had the account, name and formatted phone number in it.

 

 

See Also: SUNSORT, Utilities

 



System Utilities