25

我只是想知道如何使 MEMUSAGE 列按降序或升序排列。我搜索了整个网络,但仍然没有找到答案,我得到的最接近的一点是:

tasklist | sort

但是当我尝试使用 /m 进行排序时...:

tasklist | sort /m
Invalid switch.

谢谢你的帮助。

4

6 回答 6

24
C:\> tasklist | sort /R /+58

幻数58取决于您的输出。
根据列中的字符对文件进行排序58(不保证!)。

注意:我还需要按“Mem Usage”列对 TASKLIST 进行排序。按第n列排序不友好时对我来说有点累,它是n个字符

在我的计算机上,“Mem Usage”列是第 68 列,我必须将其粘贴到记事本中以帮助正确计算。这是命令行:

tasklist | sort /R /+68
于 2012-03-12T03:27:24.410 回答
19

在管道传输到 SORT 之前,在 TASKLIST 中启用 /NH 选项。这会抑制与 SORT 混淆的表头。

TASKLIST /NH | SORT
于 2013-05-17T18:41:09.177 回答
7

实际上,您需要做的就是输入以下内容:

tasklist | sort (This will sort the list items in ascending order)

tasklist | sort /R (This will sort the list items in descending order)

如果您键入:排序/?您可以看到 /R 按降序列出项目的位置,详细信息请参见下文:

C:\windows\system32>sort /?
SORT [/R] [/+n] [/M kilobytes] [/L locale] [/REC recordbytes]
  [[drive1:][path1]filename1] [/T [drive2:][path2]]
  [/O [drive3:][path3]filename3]
  /+n                         Specifies the character number, n, to
                              begin each comparison.  /+3 indicates that
                              each comparison should begin at the 3rd
                              character in each line.  Lines with fewer
                              than n characters collate before other lines.
                              By default comparisons start at the first
                              character in each line.
  /L[OCALE] locale            Overrides the system default locale with
                              the specified one.  The ""C"" locale yields
                              the fastest collating sequence and is
                              currently the only alternative.  The sort
                              is always case insensitive.
  /M[EMORY] kilobytes         Specifies amount of main memory to use for
                              the sort, in kilobytes.  The memory size is
                              always constrained to be a minimum of 160
                              kilobytes.  If the memory size is specified
                              the exact amount will be used for the sort,
                              regardless of how much main memory is
                              available.

                              The best performance is usually achieved by
                              not specifying a memory size.  By default the
                              sort will be done with one pass (no temporary
                              file) if it fits in the default maximum
                              memory size, otherwise the sort will be done
                              in two passes (with the partially sorted data
                              being stored in a temporary file) such that
                              the amounts of memory used for both the sort
                              and merge passes are equal.  The default
                              maximum memory size is 90% of available main
                              memory if both the input and output are
                              files, and 45% of main memory otherwise.
  /REC[ORD_MAXIMUM] characters Specifies the maximum number of characters
                              in a record (default 4096, maximum 65535).
  /R[EVERSE]                  Reverses the sort order; that is,
                              sorts Z to A, then 9 to 0.
  [drive1:][path1]filename1   Specifies the file to be sorted.  If not
                              specified, the standard input is sorted.
                              Specifying the input file is faster than
                              redirecting the same file as standard input.
  /T[EMPORARY]
    [drive2:][path2]          Specifies the path of the directory to hold
                              the sort's working storage, in case the data
                              does not fit in main memory.  The default is
                              to use the system temporary directory.
  /O[UTPUT]
    [drive3:][path3]filename3 Specifies the file where the sorted input is
                              to be stored.  If not specified, the data is
                              written to the standard output.   Specifying
                              the output file is faster than redirecting
                              standard output to the same file.

这是在 Windows 2008 服务器和 Windows 7 SP1 上测试的

于 2014-03-07T01:59:35.397 回答
0

也可以使用长护发素:

任务清单 | 排序 /memory /type /R /+35

非常整齐地按进程的内存使用情况排序

(注意:不能同时使用两种搜索,不是简单的像任务管理器更改选项一样,上面的Roger脚本最初可以工作,但是使用这个我的(又是Roger类型)(*youngster版本类型)脚本后就不能再工作了.

:)

这是 Peer1 DC /Dell / Windows Vista 类型的脚本。

于 2019-12-10T15:47:30.923 回答
0

按 PID 编号对结果进行排序:

C:\> tasklist /NH | sort /R /+29

/NH用于“无标题” - 它跳过任务列表视图的标题

/R用于反向排序(降序)

/+29表示倒序从第 30 个字符开始(所以在第 29 个字符之后)

这适用于服务器、家庭或专业版本上的所有 Windows CMD 提示符。

于 2020-02-26T17:03:09.137 回答
-1

好的,所以忽略我的消息,没有正确阅读问题。我以为他们只是想让任务列表按升序或降序排序。

我会补充一点,如果他们想按升序列出内存列,则如下所示:

tasklist | sort /+58

/R 告诉 sort 按降序列出项目。

于 2014-03-07T02:05:39.880 回答