Note 102.79 Undocumented VMS Features 79 of 80 XDELTA::HOFFMAN "Steve; VMS Engineering" 97 lines 12-MAR-1996 13:16 -< Using SORT on seq file with non-sortable header >- -------------------------------------------------------------------------------- Article 142299 of comp.os.vms: Path: nntpd.lkg.dec.com!depot.mro.dec.com!pa.dec.com!news1.digital.com!decwrl!lll-winken.llnl.gov!fnnews.fnal.gov!nntp-server.caltech.edu!seqaxp.bio.caltech.edu!MATHOG From: mathog@seqaxp.bio.caltech.edu Newsgroups: comp.os.vms Subject: Re: SORT, keep N lines??? Date: 8 Mar 1996 18:47:34 GMT Organization: Biology Division, Caltech, Pasadena CA 91125 Lines: 82 Message-ID: <4hpvc6$pvd@gap.cco.caltech.edu> References: <6205214@MVB.SAIC.COM> Reply-To: mathog@seqaxp.bio.caltech.edu NNTP-Posting-Host: seqaxp.bio.caltech.edu In article <6205214@MVB.SAIC.COM>, "GWDGV1::MOELLER" writes: >re the problem posed by D.Mathog: > >>Often I need to sort a sequential file that has these contents >> >> header >> : >> delimiter >> : >> stuff to sort >> > >A rather low-overhead solution can possibly be had from using PPFs >(process permanent files, i.e. files opened by DCL). For example, > > $ open/read INPUT {inputfile} > $ open/write OUTPUT {outputfile} > $! > $ {command that copies the header from INPUT to OUTPUT} > $! > $ SORT/{qualifiers} INPUT OUTPUT > $! > $ close INPUT > $ close OUTPUT > >SORT has no problem reading the left-over lines from INPUT, >and appending its sorted output to OUTPUT; some I/O optimizations >may be inhibited, though. It seems like black magic, but Wolfgang is right, this works exactly as advertised: $ create test.txt abc abcd abcde abcdef 1 2 3 4 5 6 7 8 9 $ open/read input test.txt $ open/write output test_out.txt $! move first 4 lines $ read input string $ write output string $ read input string $ write output string $ read input string $ write output string $ read input string $ write output string $! sort the rest $ sort/key=(pos:1,size:1,descending) input output $ close input $ close output $ type test_out.txt abc abcd abcde abcdef 9 8 7 6 5 4 3 2 1 Thanks for the suggestion! David Mathog mathog@seqaxp.bio.caltech.edu Manager, sequence analysis facility, biology division, Caltech