有时候需要列出指定目录下最新的文件或文件夹的汇总列表:
[system@hlw index]$ ls -lt */* | more
W/appTheme.ios:
总计 12
drwxr-xr-x 2 system ben 4096 05-12 02:35 20150512023001
drwxr-xr-x 2 system ben 4096 05-11 02:35 20150511023001
drwxr-xr-x 2 system ben 4096 05-10 02:35 20150510023001
Y/bread:
总计 12
drwxr-xr-x 2 system ben 4096 05-12 02:14 20150512020040
drwxr-xr-x 2 system ben 4096 05-11 02:14 20150511020040
drwxr-xr-x 2 system ben 4096 05-10 02:14 20150510020040
Y/video:
总计 8
drwxr-xr-x 2 system ben 4096 05-12 02:10 20150512020520
drwxr-xr-x 2 system ben 4096 05-11 02:15 20150511020518
Y/comic:
总计 12
drwxr-xr-x 2 system ben 4096 05-12 02:10 20150512020520
drwxr-xr-x 2 system ben 4096 05-11 02:15 20150511020519
drwxr-xr-x 2 system ben 4096 05-10 02:10 20150510020520
最终要的数据:
[system@hlw index]$ ls -lt */* | grep -C 1 "总计"|grep -v '总计'|grep -v '\-\-'|sed 's#:#/#g'|awk '{print $NF}'|awk '{if(NR%2==1){printf $0} else {print $0}}'
W/appTheme.ios/20150512023001
Y/bread/20150512020040
Y/video/20150512020520
Y/comic/20150512020520
根据实际情况有些可能需要修改或者不要 比如:“grep -v '\-\-'”
阅读(1051) | 评论(0) | 转发(0) |