我在此站点上通过 ls 排序看到了很多问题
但是我需要的是排序后的输出 ls -ltr (按文件名排序)
因为我还需要文件大小和日期以便进行比较。
我尝试了 |排序-k , | , ls-1ltr 失败
这是未排序的列表:
ser@xeroxsqa02:/app/java/jars> ls -ltr
total 41940
-rwxr-xr-x 1 xeroxadmin mqm 331471 May 10 2017 spring-aop-3.1.1.RELEASE.jar
-rwxr-xr-x 1 xeroxadmin mqm 153115 May 10 2017 jdom-1.1.jar
-rwxr-xr-x 1 xeroxadmin mqm 185140 May 10 2017 commons-io-2.4.jar
-rwxr-xr-x 1 xeroxadmin mqm 279193 May 10 2017 commons-lang-2.5.jar
-rwxr-xr-x 1 xeroxadmin mqm 489884 May 10 2017 log4j-1.2.17.jar
-rwxr-xr-x 1 xeroxadmin mqm 53081 May 10 2017 spring-asm-3.1.1.RELEASE.jar
-rwxr-xr-x 1 xeroxadmin mqm 2095932 May 10 2017 ojdbc5-11.2.0.3.0.jar
-rwxr-xr-x 1 xeroxadmin mqm 4467 May 10 2017 aopalliance-1.0.jar
-rwxr-xr-x 1 xeroxadmin mqm 38460 May 10 2017 joda-convert-1.2.jar
-rwxr-xr-x 1 xeroxadmin mqm 1891110 May 10 2017 guava-13.0.1.jar
-rwxr-xr-x 1 xeroxadmin mqm 589824 May 10 2017 spring-beans-3.1.1.RELEASE.jar
-rwxr-xr-x 1 xeroxadmin mqm 449324 May 10 2017 spring-core-3.1.1.RELEASE.jar
-rwxr-xr-x 1 xeroxadmin mqm 232019 May 10 2017 commons-beanutils-1.8.3.jar
-rwxr-xr-x 1 xeroxadmin mqm 831068 May 10 2017 spring-context-3.1.1.RELEASE.jar
-rwxr-xr-x 1 xeroxadmin mqm 569231 May 10 2017 joda-time-2.0.jar
-rwxr-xr-x 1 xeroxadmin mqm 52915 May 10 2017 commons-logging-1.1.jar
-rwxr-xr-x 1 xeroxadmin mqm 107225 May 10 2017 spring-context-support-3.1.1.RELEASE.jar
-rwxr-xr-x 1 xeroxadmin mqm 176311 May 10 2017 spring-expression-3.1.1.RELEASE.jar
drwxr-xr-x 2 xeroxadmin mqm 46 Jun 30 2017 bkp
-rwxr-xr-x 1 xeroxadmin mqm 1599570 Jan 17 19:12 axis-1.4.jar
-rwxr-xr-x 1 xeroxadmin mqm 79796 Jan 17 19:12 commons-discovery-0.5.jar
-rwxr-xr-x 1 xeroxadmin mqm 148429 Jan 17 19:12 wsdl4j-1.6.2.jar
答案 0 :(得分:1)
您是否尝试过以下操作:
ls -lru
每个手册页:
-u
和-lt
:按访问时间排序并显示;使用-l
:显示访问时间并按名称排序;否则:按访问时间排序,最新的优先
答案 1 :(得分:1)
将环境变量$ LC_COLLATE设置为适当的值 例如。
LC_COLLATE=en_US ls -l1va
在外壳脚本中,在启动时设置
export LC_COLLATE=en_US