find命令的主要功能是在系统中查找文件或目录:
find命令的一般形式为:find pathname -options [-print -exec -ok]
print为对匹配文件输出到标准输出,默认为标准输出,故可不写
exec为对匹配文件执行该参数给出的shell命令,形式为'command' {} \;
ok与exec类似,更安全,每步需要用户确认。
1.-name 根据文件名匹配。例如:
find ~ -name "test.txt" 在home路径及子目录下查找test.txt文件。
find . -name "[a-z][A-Z][0-9][0-9]*" 在当前路径及子目录下查找,一个小写字母加一个大写字母加两个数字开头的文件。
find / -name "*.txt" 查找所有txt文件。
2.-perm(permission)根据权限匹配。例如:
find . -perm 777 查找当前及子目录下所有权限为777的文件。(777意义详见chmod)
find . -perm -777 查找权限大于等于777的文件。+为小于等于。
3.-user 根据用户匹配。例如:
find . -user abc 查找abc属主的文件。
4.-nouser 查找属主账户已经被删除的文件。例如:
find . -nouser
5.-group,-nogroup 与user,nouser类似。
6.-mtime 根据更改时间匹配。例如:
find . -mtime -3 3天以内的
find . -mtime +4 4天以前的
7.-newer 根据更改时间匹配。例如:
find . -newer abc 更改时间比abc文件新的文件。
find . -newer abc ! -newer 123 -exec ls -l {} \; 更改时间比abc新但比123旧的文件,列出其详细信息。!为逻辑非。
8.-type 根据文件类型匹配。
文件类型:
b:块设备文件
d:目录
c:字符设备文件
p:管道文件
l:符号链接文件
f:普通文件
例如:
find . -type f #查找普通文件
$find . -type d -name 16M_Image #查找特定目录
9.-size 根据文件长度匹配。例如:
find . -size +1000000c 文件大于1M字节的文件。注意数字后面的c,c代表用字节计量。
find . -size 10 文件等于512块的文件。数字后没有c时,表示用块(1块=512字节)计量。
10.还可与xargs命令一同使用(后续介绍)。
======================================================================================
======================================================================================
linux find command
==========================================
格式: find [path...] [expression]
find / -name access_log 2>/dev/null 不显示错误信息
find / -amin n ##查找系统中最后N分钟访问的文件
find / -atime n ##查找系统中最后n*24小时访问的文件
find / -cmin n ##查找系统中最后N分钟被改变状态的文件
find / -ctime n ##查找系统中最后n*24小时被改变状态的文件
find / -empty ##查找系统中空白的文件,或空白的文件目录,或目录中没有子目录的文件夹
find / -false ##查找系统中总是错误的文件
find / -fstype type ##查找系统中存在于指定文件系统的文件,例如:ext2 .
find / -gid n ##查找系统中文件数字组 ID 为 n的文件
find / -group gname ##查找系统中文件属于gnam文件组,并且指定组和ID的文件
find / -mmin n # 查找在系统中最后n分钟里修改过的文件
find / -mtime n #查找在系统中最后24*n小时里修改过的文件
find / -nouser #查找在系统中属于作废用户的文件
find / -size nc #查找在系统中长度为n字节的文件
find / -size +nc #查找在系统中长度大于n字节的文件
find / -daystart ##测试系统从今天开始24小时以内的文件,用法类似-amin
find / -depth ##使用深度级别的查找过程方式,在某层指定目录中优先查找文件内容
find / -follow ##遵循通配符链接方式查找; 另外,也可忽略通配符链接方式查询
find / -help ##显示命令摘要
find / -maxdepth levels ##在某个层次的目录中按照递减方法查找
find / -mount ##不在文件系统目录中查找, 用法类似 -xdev.
find / -noleaf ##禁止在非UNUX文件系统,MS-DOS系统,CD-ROM文件系统中进行最优化查找
find / -version ##打印版本数字
-exec command; ##查找并执行命令
-fprint file ##打印文件完整文件名
-fprint0 file ##打印文件完整文件名包括空的文件
-fprintf file format ##打印文件格式
-ok command; ##给用户命令执行操作,根据用户的Y 确认输入执行
-printf format ##打印文件格式
-ls ##打印同种文件格式的文件.
几个参数之间可以用-and,-or连接,某个参数取反可用!
======================
用man find可以看到下面的说明:
-mtime n
Files data was last modified n*24 hours ago. ===> man find里面解释错误
find -mtime 4 是找到所有5天前4天后被更改的档案文件,
find -mtime -4 是4天内被改的档案,
find -mtime +4 是4天后被改的档案。
======================
查看某目录下有多少个文件命令:
# find DirPath -type f | wc -l
比如: find /home/snail -type f | wc -l
如果想查看 src 目录下有多少 C 文件,如下:
# find ./src -type f -name "*.c" | wc -l
find 命令的 -type 后的参数有以下选择,每种都代表不一样的“类型(type)”
-type 文件类型
b 块文件(比如内存)
c 字符文件(比如串口)
d 目录文件(目录也是一种文件)
p 有名管道(FIFO)
f 普通文件
l 符号链接(如果使用 -L 或 -follow 选项则不起作用,除非链接损坏)
s socket文件(比如 /tmp/mysql.sock)
D door (Solaris)
======================
文件查找命令 find
find 用于查找文件系统中指定文件,其格式为: find 要查找的路径 表达式
例如: find . -name 1.txt \\ 在当前目录及其子目录下查找文件1.txt
find /tmp -name 1.txt \\ 在/tmp 目录及其子目录下查找文件1.txt
======================
查找Linux下的空目录技巧
if [ -z "$1" ]; then
echo Usage: $0 \
exit 1
fi
echo -e Null directory list:
for i in $(find $1 -type d -print)
do
TMP=$(ls $i)
if [ "$TMP" = "\." ]; then
continue
elif [ -z "$TMP" ]; then
echo $i
fi
done
======================
发表评论
-
glibc版本信息及安装
2017-12-28 15:42 1404在高版本的glibc上编译的不能到底版本的glibc ... -
论GNU、Linux和GNU/Linux之间的关系
2017-12-28 15:17 364相信很多人看到了这个标题就会产生疑问,这篇文章到底要讲 ... -
linux的软链接与硬链接
2017-11-03 16:25 321Linux链接分两种,一 ... -
使用mailx发送邮件
2013-04-12 10:57 961mailx是UNIX系统上用来处理邮件的工具,使用它可以发送, ... -
查看linux系统信息
2013-02-25 18:58 921Linux系统信息查看命令大全 系统 # uname -a ... -
ssh 常用用法小结
2013-02-25 18:21 1855ssh 常用用法小结 在 ... -
在windows中使用UltraEdit编辑linux下文件
2013-01-18 13:21 5920在windows中使用UltraEdit编辑linux下文件 ... -
beyondCompare 工具比较linux下文件夹
2013-01-18 11:56 1223在windows环境下,用beyondCompare 工 ... -
Linux 目录结构以及作用详解
2013-01-06 14:58 7621、什么是文件系统 当 ... -
Linux通过脚本实现远程自动备份
2013-01-05 16:43 797考虑到在本机上备份数据,一旦该机器硬盘出现故障,数 ... -
Linux的僵尸进程及其解决方法
2013-01-05 16:36 7451. 产生原因: ... -
linux之cp/scp命令+scp命令详解
2012-12-25 16:34 944名称:cp使用权限:所有使用者使用方式:cp [options ... -
过滤小结(Linux)
2012-12-20 16:32 0============================ $ ... -
十项Linux操作系统安全管理技巧经验总结
2012-12-18 16:23 631由于Linux操作系统是一个开放源代码的免费操作系统,因此 ... -
Linux磁盘管理中quota命令介绍应用
2012-12-18 14:33 1340Quota 在Linux里,quota就是对硬盘进行限制 ... -
linux中ssh 连接缓慢解决方法
2012-12-13 13:30 1251重新安装机器的情况下 ... -
Redhat linux 命令行设置IP
2012-12-11 14:27 1244redhat linux版本命令行设置IP ifcon ... -
Linux软件包安装方式小结
2012-12-11 10:45 799Linux操作系统软件包安 ... -
Linux压缩解压的相关命令总结
2012-12-11 10:32 790Linux下常用压缩格 ... -
Linux下Python的安装方法
2012-11-29 18:41 724Linux下Python的安装方法: 1.下载源代码 ht ...
相关推荐
Slice and dice text files with cut, paste, grep, patch, and sed Once you overcome your initial 'shell shock,' you'll find that the command line is a natural and expressive way to communicate with your...
Slice and dice text files with cut, paste, grep, patch, and sed Once you overcome your initial 'shell shock,' you'll find that the command line is a natural and expressive way to communicate with your...
linux-command Linux命令大全搜索工具,内容包含Linux命令手册、详解、学习、搜集。 Linux命令分类 这里存放Linux 命令大全并不全,你可以通过linux-command来搜索,它是把 command ...
Once you overcome your initial "shell shock," you'll find that the command line is a natural and expressive way to communicate with your computer. Just don't be surprised if your mouse starts to ...
find path -option [ -print ] [ -exec -ok command ] {} \; 参数说明 : find 根据下列规则判断 path 和 expression,在命令列上第一个 – ( ) , ! 之前的部份为 path,之后的是 expression。如果 path 是空字串则
linux 命令一览表 alias Create an alias • apropos Search Help manual pages (man k) aptget Search for and install software packages (Debian/Ubuntu) aptitude Search for and install software ...
find是我们很常用的一个Linux命令,但是我们一般查找出来的并不仅仅是看看而已,还会有进一步的操作,这个时候exec的作用就显现出来了。 exec解释: -exec 参数后面跟的是command命令,它的终止是以;为结束标志的,...
·find path -option [ -print ] [ -exec -ok command ] {} ; find命令的参数; pathname: find命令所查找的目录路径。例如用.来表示当前目录,用/来表示系统根目录。 -print: find命令将匹配的...
该为weblogic12.2.1.3版本opatch13.9.4.0.0升级包,另外weblogic漏洞升级说明文档在我另外一个资源包里
Linux find命令用来在指定目录下查找文件。任何位于参数之前的字符串都将被视为欲查找的目录名。如果使用该命令时,不设置任何参数,则find命令将在当前目录下查找子目录与文件。并且将查找到的子目录和文件全部进行...
The file system layout of Linux systems and where to find programs, configurations, and documentation. The basic Linux commands you'll use most often. Creating, renaming, moving, and deleting ...
Throw in a host of valuable power user tips and a friendly and accessible style, and you'll quickly find this practical, to-the-point book a small but mighty resource for Linux users.
brief Linux command that will moreeasy to find
BusyBox 是一个集成了三百多个最常用Linux命令和工具的软件。BusyBox 包含了一些简单的工具,例如ls、cat和echo等等,还包含了一些更大、更复杂的工具,例grep、find、mount以...
Learn Raspberry Pi with Linux will tell you everything you need to know about the Raspberry Pi's GUI and command line so you can get started doing amazing things. You'll learn how to set up your new ...
In easy-to-follow lessons designed to take an hour or less, you'll learn how to use the command line, along with practical topics like installing software, customizing your desktop, printing, and ...
这时我们并没有真正的安装上了VMWARE TOOLS软件包,如果您点击菜单:DEVICES,您就会发现光驱的菜单文字变为:ide1:0-> C:\Program Files\VMware\VMware Workstation\Programs\linux.iso,这表示VMWARE将LINUX的ISO...
But this is no mere command reference or novice's introduction. Shah doesn't shy away from explaining the really interesting aspects of Linux administration, including kernel compilation, Domain Name ...
You'll find a road map to the commands and processes you need to be instantly productive. What's Inside Master the command line Learn about file systems Understand desktop environments Go from ...
Cannot find module '/home/user/.nvm/versions/node/v8.11.3/lib/node_modules/composer-cli/node_modules/grpc/src/node/extension_binary/node-v59-linux-x64-glibc/grpc_node.node'