Article View: comp.unix.shell
Article #1531Re: How to sort on exactly one field only
From: Stephen Quan
Date: Wed, 24 Oct 1990 02:34
Date: Wed, 24 Oct 1990 02:34
28 lines
1221 bytes
1221 bytes
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.
Technical Details
Message-ID:
<quan.656735656@sol>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!munnari.oz.au!diemen!sol!quanReferences:
<1094@massey.ac.nz>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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: <quan.656735656@sol> 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