from sort --man (or sort --?unstable)
Unstable sort. When all keys compare equal, break the
tie by using the entire record, ignoring all but the
-r option. This is the default.
in your case its the equivalent of using field 1 to break ties
On Wed, 20 Jan 2010 21:47:39 -0500 gene golub wrote:
> Hi All=2C
> =20
> I have 2 silly questions.=20
> I am going to have a file which is delimited by bang symbol (|).
> 1st and 2nd fields are numeric.
> I need to sort by 2nd=2C 1st field.
> I beleive my sort command will look like:
> =20
> sort -t | -k 2=2C2n -k 1=2C1n file_name
> =20
> Above command seems to work. However=2C if I omit second sort qualifier an=
> d run:
> =20
> sort -t | -k 2=2C2n file_name=20
> =20
> It still produces the right result.
> Why?
> =20
> ... and second question:
> According to man pages '-k b[n]=2C[e][n] m defines beginning sort field and=
> e - ending sort field.
> =20
> Should be correct coding for 2nd and 1st field be -k 2=2C3 -k 1=2C2 ?
> =
> --_def73c17-dab5-49f5-b67f-94111e9f6e03_
> Content-Type: text/html; charset="iso-8859-1"
> Content-Transfer-Encoding: quoted-printable
> <html>
> <head>
> <style><!--
> .hmmessage P
> {
> margin:0px=3B
> padding:0px
> }
> body.hmmessage
> {
> font-size: 10pt=3B
> font-family:Verdana
> }
> --></style>
> </head>
> <body class=3D'hmmessage'>
> Hi All<BR>
> Hi All=2C<BR>
>  =3B<BR>
> I have 2 silly questions. <BR>
> I am going to have a file which is delimited by bang symbol (|).<BR>
> 1st and 2nd fields are numeric.<BR>
> I need to sort by 2nd=2C 1st field.<BR>
> I beleive my sort command will look like:<BR>
>  =3B<BR>
> sort -t | -k 2=2C2n -k 1=2C1n file_name<BR>
>  =3B<BR>
> Above command seems to work. However=2C if I omit =3B second sort quali=
> fier and run:<BR>
>  =3B<BR>
> sort -t | -k 2=2C2n file_name <BR>
>  =3B<BR>
> It still produces the right result.<BR>
> Why?<BR>
>  =3B<BR>
> ... and second question:<BR>
> According to man pages '-k b[n]=2C[e][n] m defines beginning sort field&nbs=
> p=3Band e - ending sort field.<BR>
>  =3B<BR>
> Should be correct coding for 2nd and 1st field be -k 2=2C3 -k 1=2C2 ?<BR>
> =
> </body>
> </html>=
> --_def73c17-dab5-49f5-b67f-94111e9f6e03_--
> --===============0026655627==
> Content-Type: text/plain; charset="us-ascii"
> MIME-Version: 1.0
> Content-Transfer-Encoding: 7bit
> Content-Disposition: inline
> _______________________________________________
> ast-users mailing list
> [email protected]
> https://mailman.research.att.com/mailman/listinfo/ast-users
> --===============0026655627==--
_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users