Unix Sort with U
Anyone knows how this sort works? What do they [+0.2 -0.42 +0.0 -0.1 -o] mean?
CmdString.Format("sort -u +0.2 -0.42 +0.0 -0.1 -o %开发者_如何学Gos %s",
(const char *)TempFilename,
(const char *)TempFilename);
-u
option remove duplicate lines.
+f.c
and -f.c
define sorting keys:
f
represents a field numberc
represent a character number within the field from the beginning of the field when starting with+
or from the end of the previous field when starting with-
Take a look at sort man page for more precisions about it.
An info coreutils 'sort invocation'
command reveals that on older systems sort uses an obsolete +POS1 [-POS2] origin-zero syntax for specifying sort keys.
In my opinion, though, the info page is not much more helpful than the man
page, which is why there hasn't been much explanation so far, beyond a hint that the man page will help.
The "-o" is the parameter to define the output file. The rest of the + and - are defining the fields, and offsets in those fields to sort by. The manual page for sort will give all the gory details...
精彩评论