On Thu, Jul 10, 2014 at 10:18, Stuart Henderson wrote: > On 2014/07/10 09:50, Steffen Schuler wrote: >> >Synopsis: "cut -f 2,1" doesn't switch fields 1 and 2. >> >Category: Serious bug in base system. >> >Environment: >> System : OpenBSD 5.4 >> Details : OpenBSD 5.4 (GENERIC.MP) #41: Tue Jul 30 15:30:02 MDT 2013 >> >> [email protected]:/usr/src/sys/arch/amd64/compile/GENERIC.MP >> >> Architecture: OpenBSD.amd64 >> Machine : amd64 >> >Description: >> >> The following command >> >> $ echo a,b | cut -d , -f 2,1 >> prints >> >> a,b >> >> instead of >> >> b,a >> >> as the manual page of cut(1) tells. > > It would be a serious bug if cut(1) did output "b,a" for this command. > > Maybe it's a minor documentation omission, but the manual page does > not talk about order of the output fields at all.
Index: cut.1 =================================================================== RCS file: /cvs/src/usr.bin/cut/cut.1,v retrieving revision 1.22 diff -u -p -r1.22 cut.1 --- cut.1 2 Feb 2014 14:16:22 -0000 1.22 +++ cut.1 10 Jul 2014 09:31:20 -0000 @@ -88,6 +88,8 @@ Numbers and number ranges may be repeate It is not an error to select fields or columns not present in the input line. .Pp +Fields are output in the same order as input, not in the order selected. +.Pp The options are as follows: .Bl -tag -width Ds .It Fl b Ar list @@ -135,6 +137,7 @@ Show the names and login times of logged .Pp .Dl "$ who | cut -c 1-8,18-30" .Sh SEE ALSO +.Xr awk 1 , .Xr paste 1 .Sh STANDARDS The
