UNIX排序:从剪贴板中排序

时间:2021-11-06 07:41:36

The other day I saw a colleague of mine using sort to sort a number of lines he copied from a text file.

有一天,我看到我的一位同事使用sort来排序他从文本文件中复制的一些行。

I've been trying to reproduce it myself and I cannot seem to find how.

我一直试图自己重现它,我似乎无法找到它。

The requirements are as follow:

要求如下:

  • Use sort from command line, plus whatever else you need to add to configure input

    使用命令行中的sort,以及您需要添加的任何其他内容来配置输入

  • Paste the text to be sorted from the clipboard

    从剪贴板粘贴要排序的文本

  • Get the sorted result in the console

    在控制台中获取排序结果

3 个解决方案

#1


3  

If you type sort - the command will accept input from stdin. Then you can just paste whatever you want into the console and type CTRL-D to sort it.

如果键入sort - 该命令将接受来自stdin的输入。然后,您只需将所需内容粘贴到控制台中,然后键入CTRL-D即可对其进行排序。

#2


3  

Easy, just type sort (or sort -) to run on stdin, paste your lines, and hit CTRL+D for end-of-transmission to sort.

简单,只需键入sort(或sort - )即可在stdin上运行,粘贴行,然后按CTRL + D进行传输结束以进行排序。

#3


2  

Use xclip.

 xclip -o | sort -

#1


3  

If you type sort - the command will accept input from stdin. Then you can just paste whatever you want into the console and type CTRL-D to sort it.

如果键入sort - 该命令将接受来自stdin的输入。然后,您只需将所需内容粘贴到控制台中,然后键入CTRL-D即可对其进行排序。

#2


3  

Easy, just type sort (or sort -) to run on stdin, paste your lines, and hit CTRL+D for end-of-transmission to sort.

简单,只需键入sort(或sort - )即可在stdin上运行,粘贴行,然后按CTRL + D进行传输结束以进行排序。

#3


2  

Use xclip.

 xclip -o | sort -