把文件名中的空格删掉
[[email protected] shell]# ll total 0 -rw-r--r-- 1 root root 0 Nov 25 15:19 9 67.sh [[email protected] shell]# ls -1 | while read a; do mv "$a" `echo $a | sed -e ‘s/\ //g‘`; done [[email protected] shell]# ll total 0 -rw-r--r-- 1 root root 0 Nov 25 15:19 967.sh |
按访问时间列出sh文件
[[email protected] shell]# ls -lt --time=atime *.sh -rw-r--r-- 1 root root 0 Nov 25 15:27 967.sh -rw-r--r-- 1 root root 0 Nov 25 15:26 6_5.sh -rw-r--r-- 1 root root 0 Nov 25 15:26 9_17.sh -rw-r--r-- 1 root root 0 Nov 25 15:26 8.sh [[email protected] shell]# ls -ltu *.sh -rw-r--r-- 1 root root 0 Nov 25 15:27 967.sh -rw-r--r-- 1 root root 0 Nov 25 15:26 6_5.sh -rw-r--r-- 1 root root 0 Nov 25 15:26 9_17.sh -rw-r--r-- 1 root root 0 Nov 25 15:26 8.sh |
统计文件名中常见的文字
[[email protected] shell]# ll total 144 -rw-r--r-- 1 root root 0 Nov 25 15:26 6_5.sh -rw-r--r-- 1 root root 0 Nov 25 15:26 8.sh -rw-r--r-- 1 root root 0 Nov 25 15:19 967.sh -rw-r--r-- 1 root root 0 Nov 25 15:26 9_17.sh -rw-r--r-- 1 root root 143538 Nov 23 10:17 shell.txt [[email protected] shell]# ls | tr ‘[[:punct:][:space:]]‘ ‘\n‘ | grep -v "^\s*$" | sort | uniq -c | sort -bn 1 17 1 5 1 6 1 8 1 9 1 967 1 shell 1 txt 4 sh |
找到文件夹中带软链接的
[[email protected] shell]# ls -la | grep ^l lrwxrwxrwx 1 root root 9 Nov 25 15:56 s.txt -> shell.txt |
查当前目录及以下目录中大于50K的文件
[[email protected] shell]# find . -type f -size +50k -exec ls -lh {} \; | awk ‘{ print $9 ": " $5 }‘ ./shell.txt: 141K ./dd/88.sh: 140K |