Sort Variable Pipe Delimited Records enclosed by quotes
Input File 1 - PipeDelim2.txt
Smith|123 Main Street|Little Rock|AR|72201 Service|Misty Marie Lane|Ketchikan|Alaska|99950 Wilson|33 Arch St|Fort Campbell|KY|42223 "James|or current resident"|Mockingbird Ln|Dallas|TX|75201 Frank|"34th Ave|Drawer 1"|Washington|DC|20521 Lemon|"77 Cliff Dr|Suite #2"|Agawam|MA|01002 Service Manager||Holtsville|NY|00501
Sort Control Cards - PipeDelim2Ctl.txt
RECORD TYPE=T,LENGTH=1000 * Sort by ZIP Code, Delimited Field #1 * Fields can be optionally be enclosed by " SORT FIELDS=(#5,CH,A),FS='|',FieldsOptionallyEnclosedBy='"' END
Command Line
> ahlsort PipeDelim2Ctl.txt PipeDelim2.txt PipeDelim2Sorted.txt
Output File - PipeDelim2Sorted.txt
Service Manager||Holtsville|NY|00501 Lemon|"77 Cliff Dr|Suite #2"|Agawam|MA|01002 Frank|"34th Ave|Drawer 1"|Washington|DC|20521 Wilson|33 Arch St|Fort Campbell|KY|42223 Smith|123 Main Street|Little Rock|AR|72201 "James|or current resident"|Mockingbird Ln|Dallas|TX|75201 Service|Misty Marie Lane|Ketchikan|Alaska|99950