Xref: utzoo comp.unix.shell:695 comp.unix.questions:26440 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!munnari.oz.au!diemen!sol!quan From: quan@sol.surv.utas.oz (Stephen Quan) Newsgroups: comp.unix.shell,comp.unix.questions Subject: Re: How to sort on exactly one field only Message-ID: Date: 24 Oct 90 02:34:16 GMT References: <1094@massey.ac.nz> Sender: news@diemen.utas.edu.au Followup-To: comp.unix.shell Lines: 28 ARaman@massey.ac.nz (Anand Venkata Raman) writes: >I want to sort a file exclusively on field #2. >For example, >A portion of the file looks like >appl1 3 Submitted >appl2 4 Submitted >appl1 3 Started >appl3 5 Submitted >appl2 4 Started >appl1 3 Finished(0) >appl2 4 Finished(7) >appl3 5 Started >appl3 5 Finished(3) In the bourne shell (sh) : cat -n file | awk "{print \$3,\$1,\$2,\$4}" | sort | awk "{print \$3,\$1,\$4}" - line numbers are added - arguments are rearrange so : - sort is done on first preference your key, second preference line numbers - remove the line# are rearrange arguments back I think I am missing some argument to 'sort' to make it interpret the line numbers as numbers - not just text. Stephen Quan, University of Tasmania.