find–links第二发:
在使用find的过程中,links后面可以跟上一个参数,并且这个参数存在三种情况:
find./ -type d –links
n --à代表查找当前目录下面的文件只有n那个连接,(hard-links)
-n --à代表查找当前目录下面的文件少于n那个连接,(hard-links)
+n --à代表查找当前目录下面的文件多于n那个连接,(hard-links)
当前目录下面
tree3
3
test1
hello
hellot4est
helloworld
hi
test2
在3目录下面有三个一级目录,其中的一级目录 hello下面有一个子目录为hello4est。
find./3 -type d -links 2
./3/test1/hello/hellot4est
./3/test1/hi
./3/test1/helloworld
./3/test2
find./3 -type d -links +2
./3
./3/test1
./3/test1/hello
find./3 -type d -links 5
./3/test1
find./3 -type d -links -2
解析:
一个文件自己本身就存在连个硬链接,如果自己的目录下面多一个子目录,那么本身目录会多存在一个..的硬链接,所以可以通过判断链接的数量来判断目录下面的子目录的个数。