find查找
(1)根據(jù)文件名,類型查找
[root@lsr7 ~]# find / -type d -name 'ip' //查找/下面類型是目錄,名字是ip的
/usr/src/kernels/3.10.0-957.5.1.el7.x86_64.debug/include/config/ip
/usr/src/kernels/3.10.0-957.5.1.el7.x86_64.debug/include/config/net/ip
[root@lsr7 ~]# find oldboy -type f -name '*.txt' //查看oldboy目錄,里面以txt為結(jié)尾的文件
find: warning: you have specified the -maxdepth option after a non-option argument -type, but options are not positional (-maxdepth affects tests specified before it as well as those specified after it). Please specify options before other arguments. //警告信息-maxdepth要放在前面
(2)根據(jù)-maxdepth(文件深度查找)
[root@lsr7 oldboy]# find / -maxdepth 1 -type d //-maxdepth(最多深度)1層次是1 -type d類型是目錄
/
/dev
/home
/proc
/run
/sys
[root@lsr7 ~]# find /etc/ -maxdepth 1 -type f -iname .conf //找出/etc/目錄下面第1層目錄中以.conf結(jié)尾的文件(不區(qū)分大小寫)(mai si di pai te)
/etc/resolv.conf
/etc/libaudit.conf
(3)! 取反
[root@lsr7 ~]# find /etc/ -type f ! -iname '.conf' //查找/etc/目錄下除了conf的其它文件(不區(qū)分大小寫)
/etc/zlogout
/etc/zprofile
/etc/zshenv
(4)size 根據(jù)大小查找文件
[root@lsr7 ~]# find /etc/ -size +1M //查找/etc/下大于1M的文件
[root@lsr7 ~]# find /etc/ -size -5k //查找/etc/下小于5k的文件
- xargs分組(只有xargs和tr用<)
[root@lsr7 ~]# echo {A..Z} > oldboy/huahua.txt
[root@lsr7 ~]# cat oldboy/huahua.txt
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
[root@lsr7 ~]# xargs -n5 < oldboy/huahua.txt
A B C D E
F G H I J
K L M N O
P Q R S T
U V W X Y
Z