巴什有点像Windows的自然排序顺序' [英] Bash Sort like Windows 'natural sort order'
问题描述
我有一大堆,我试图追加在一起的PDF文件,而我有一个程序,给定的文件列表,将它们添加到一个PDF。
I've got a bunch of PDFs that I'm trying to append together, and I've got a program that, given a list of files, will append them to one PDF.
我遇到的问题是,通过管道将文件名设置为排序不会产生所需的顺序。的国旗无排序给我什么,我想无论是。我有下面的一些例子:
The issue I'm having is that piping the file names to sort does not produce the desired order. None of the flags of sort give me what I want either. I've got some examples below:
所需的排序顺序:
test1.pdf
test2.pdf
test10.pdf
实现排序顺序使用排序
test1.pdf
test10.pdf
test2.pdf
有关什么构成排序顺序我渴望更多信息,请参见:
For more info on exactly what constitutes the sort order I desire, see:
<一个href=\"http://msdn.microsoft.com/en-us/library/bb759947.aspx\">http://msdn.microsoft.com/en-us/library/bb759947.aspx
推荐答案
假设你正在使用的GNU排序,使用 -V
选项:
Assuming you're using GNU sort, use the-V
option:
-V, --version-sort
natural sort of (version) numbers within text
有关您的输入,它会产生:
For your input, it'd produce:
test1.pdf
test2.pdf
test10.pdf
这篇关于巴什有点像Windows的自然排序顺序'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!