我有一个文件列表,其中包含我需要排序的版本号
/this/is/a/file/path/product-2.0/file/name/7
/this/is/a/file/path/product-2.0/file/name/10
/this/is/a/file/path/product-2.0/file/name/12
/this/is/a/file/path/product-2.0/file/name/13
/this/is/a/file/path/product-2.0/file/name/6
/this/is/a/file/path/product-2.0/file/name/8
/this/is/a/file/path/product-2.0/file/name/9
Run Code Online (Sandbox Code Playgroud)
当我通过grep管道时它就像这样:
echo $files | sort -n
/this/is/a/file/path/product-2.0/file/name/10
/this/is/a/file/path/product-2.0/file/name/12
/this/is/a/file/path/product-2.0/file/name/13
/this/is/a/file/path/product-2.0/file/name/6
/this/is/a/file/path/product-2.0/file/name/7
/this/is/a/file/path/product-2.0/file/name/8
/this/is/a/file/path/product-2.0/file/name/9
Run Code Online (Sandbox Code Playgroud)
我认为-n被文件名中的第一个数字搞糊涂了.
我怎样才能用最后一个数字对它进行数字排序
我想在我的vimrc中添加一些内容,这样如果我打开2个文件,它们会自动在单独的分割窗口中打开.我不想开始使用它,-o因为我有时会打开很多文件,并且有15个以上的分割效果不会很好.所以我想要一些逻辑来检查打开了多少文件,如果是2则将每个文件放入自己的分割窗口.
谢谢
PS我最常用这个来查看c ++项目的.cc和.hh文件.