[email protected]:~# cd /tmp #(usually I will use this directory)
[email protected]:/tmp# ll
[email protected]:/tmp#
[email protected]:/tmp# mkdir lldir
[email protected]:/tmp# touch ll.txt old.txt new.txt
[email protected]:/tmp# ll
总用量 4
drwxr-xr-x 2 root root 4096 10月 20 21:50 lldir
-rw-r--r-- 1 root root 0 10月 20 21:47 ll.txt
-rw-r--r-- 1 root root 0 10月 20 21:47 new.txt
-rw-r--r-- 1 root root 0 10月 20 21:47 old.txt
[email protected]:/tmp# find -type f
./new.txt
./ll.txt
./old.txt
[email protected]:/tmp# find -type f -name "old"
[email protected]:/tmp# find -type f -name "old*"
./old.txt
[email protected]:/tmp# find ./ -type f -name "old*"
./old.txt
[email protected]:/tmp# find . -type f -name "old*"
./old.txt
[email protected]:/tmp# find . -type f -name "old*"|xargs rm -f
[email protected]:/tmp# ll
总用量 4
drwxr-xr-x 2 root root 4096 10月 20 21:50 lldir
-rw-r--r-- 1 root root 0 10月 20 21:47 ll.txt
-rw-r--r-- 1 root root 0 10月 20 21:47 new.txt
[email protected]:/tmp# find . -type d
.
./lldir
[email protected]:/tmp# find . -type d|grep -v "^\.$"
./lldir
[email protected]:/tmp# find . -type d|grep -v "^\.$"|xargs rm -f
rm: 无法删除"./lldir": 是一个目录
[email protected]:/tmp# find . -type d|grep -v "^\.$"|xargs rm -rf
[email protected]:/tmp# ll
总用量 0
-rw-r--r-- 1 root root 0 10月 20 21:47 ll.txt
-rw-r--r-- 1 root root 0 10月 20 21:47 new.txt
[email protected]:/tmp# mkdir lldir
[email protected]:/tmp# !tou
touch ll.txt old.txt new.txt
[email protected]:/tmp# ll
总用量 4
drwxr-xr-x 2 root root 4096 10月 20 21:58 lldir
-rw-r--r-- 1 root root 0 10月 20 21:59 ll.txt
-rw-r--r-- 1 root root 0 10月 20 21:59 new.txt
-rw-r--r-- 1 root root 0 10月 20 21:59 old.txt
[email protected]:/tmp# ll|find -t
-true -type
[email protected]:/tmp# ll|find -type f
./new.txt
./ll.txt
./old.txt
[email protected]:/tmp# ll|find -type d
.
./lldir
[email protected]:/tmp# find -type d|xargs rm -fr
rm: refusing to remove "." or ".." directory: skipping "."
[email protected]:/tmp# mkdir lldir
[email protected]:/tmp# touch ll.txt old.txt new.txt
[email protected]p:/tmp# find -type d|xargs rm -fr 2>01.log
[email protected]:/tmp# cat 01.log
rm: refusing to remove "." or ".." directory: skipping "."
[email protected]:/tmp#