2.23——2.25find命令(上中下);2.26 文件名后缀

简介:

2.23 find命令(上)
快捷键:
Ctrl + l  :清屏
Ctrl + d :退出终端(相当于执行了:exit 或logout)
Ctrl + c : 强制中断
Ctrl + u : 在命令输入行,删除光标前的字符串
Ctrl + e :  光标移到末尾
Ctrl + a :  光标移到开始
which :搜索命令文件(从echo $PATH环境变量下的目录查找)
find :搜索文件
1. find 精准搜索:find 搜索路径 -name "精准关键词"
[root@hao-01 ~]# find /root/ -name "mulu1.txt"
clipboard.png
2. find 模糊搜索:find  搜索路径 -name "模糊关键词*"
关键词后面加 * 就是把有带关键词的文件和目录都显示出来!
[root@hao-01 ~]# find /root/ -name "mulu*"
clipboard.png
3. find 只搜索带有关键词的 目录 :
find  搜索路径 -type d -name "模糊关键词*"
[root@hao-01 ~]# find /root/ -type d -name "mulu*"
clipboard.png
4. find 只搜索带有关键词的 文件:
find  搜索路径 -type f -name "模糊关键词*"
[root@hao-01 ~]# find /root/ -type f -name "mulu*"
clipboard.png
5. find 搜索指定的文件类型:
文件类型包括:
f  :(-)普通文档文件和二进制文件
l  :软链接文件(相当于Windows快捷方式)
s :通信文件                 
c  : 字符串设备(鼠标键盘)
b :块设备文件(光盘,磁盘)
2.24 find命令(中)
1. 在文件末尾追加一行内容:echo "追加内容"  >>  文件
[root@hao-01 ~]# echo "hao" >> 1.txt

stat :查看文件详细信息
stat 跟文件名
clipboard.png
atime :最近访问  (cat 命令查看文件内容 ; atime会变)
mtime:最近更改  (更改:文件的内容;mtime会变)
ctime :最近改动  (改动:权限或inode或文件名或时间等;ctime会变)
提示:更改文件内容,mtime时间会变,ctime也跟着会变!

搜索指定文件的 atime(最近访问)
1. find 搜索 (atime) cat查看就是访问时间 大于1天时间的文件:find 路径  -type f -atime +1
[root@hao-01 ~]# find /root/ -type f -atime +1
2. find 搜索 (atime) cat查看就是访问时间 小于1天时间的文件:find 路径  -type f -atime -1
[root@hao-01 ~]# find /root/ -type f -atime -1
搜索指定文件的 mtime(最近更改)
1. find 搜索(mtime) 创建或修改时间大余1天时间的文件:
find 路径  -type f -mtime +1
[root@hao-01 ~]# find /root/ -type  f  -mtime  +1
2. find 搜索(mtime)创建或修改时间小少1天时间的文件:
find 路径  -type f -mtime -1
[root@hao-01 ~]# find  /root/  -type  f  -mtime  -1
搜索指定文件的 ctime (最近更改)
1. find 搜索(ctime)更改权限或inode或文件名或时间等,大余1天时间的文件:find 路径  -type f -ctime +1
[root@hao-01 ~]# find  /root/  -type  f  -ctime  +1
2. find 搜索(ctime)更改权限或inode或文件名或时间等,小余1天时间的文件:find 路径  -type f -ctime -1
[root@hao-01 ~]# find  /root/  -type  f  -ctime  -1
find 多个判断条件搜索的:
-type f         :指定搜索的是普通文档文件
-atime -1     :指定搜索的是创建或修改时间,小于一天
-name "1.txt*" :指定搜索的是关键词
[root@hao-01 ~]#  find /root/ -type f -mtime -1 -name "1.txt*"
clipboard.png
2.25 find命令(下)
根据inode可以查找文件的硬链接: find  /(根路径) -inum  inode号
1. 根据原文件的inode号,可以查找原文件的硬链接:
[root@hao-01 ~]# find / -inum 33589250
clipboard.png
2. 搜索一小时内创建或修改的文件:
-mmin :指定分钟的意思 -60就是小于60分钟,60分钟内!
[root@hao-01 ~]# find /root/ -type f -mmin -60
3. 搜索一个小时内创建或修改的文件,同时搜索到的执行ls -l
[root@hao-01 ~]# find /root/ -type f -mmin -60 -exec ls -l ;
clipboard.png
4. 搜索一个小时内创建或修改的文件,同时搜到的执行添加后缀名
[root@hao-01 ~]# find /root/ -type f -mmin -60 -exec mv {} {}.bak \;  
[root@hao-01 ~]# find /root/ -type f -mmin -60 -exec ls -l ;
clipboard.png
5. 指定搜索文件大于10k:-size +10k
[root@hao-01 ~]# find /root/ -type f -size +10k -exec ls -lh {} \;
6. 指定搜索文件大于10M:-size +10M
[root@hao-01 ~]# find /root/ -type f -size +10M -exec ls -lh {} \;
2.26 文件名后缀
文件名的后缀,不能代表文件类型








本文转自 主内安详 51CTO博客,原文链接:http://blog.51cto.com/zhuneianxiang/2053680,如需转载请自行联系原作者

目录
相关文章
|
9天前
选择特定后缀文件/删除文件夹中文件特定后缀名字
选择特定后缀文件/删除文件夹中文件特定后缀名字
|
11月前
|
Linux
linux命令basename:去掉路径和扩展名,得到指定文件的文件名(去除文件扩展名.xxx)
linux命令basename:去掉路径和扩展名,得到指定文件的文件名(去除文件扩展名.xxx)
126 0
查找文件夹内所有文件
查找文件夹内所有文件
50 0
目录字串最后都不要带目录分隔符
目录字串最后都不要带目录分隔符
106 0
|
Linux PHP
Linux查找文件夹下包含某字符的所有文件
Linux查找文件夹下包含某字符的所有文件Linux grep 命令用于查找文件里符合条件的字符串。grep 指令用于查找内容包含指定的范本样式的文件,如果发现某文件的内容符合所指定的范本样式,预设 grep 指令会把含有范本样式的那一列显示出来。
2757 0
|
网络安全 数据库
find命令/文件名后缀
2.23/2.24/2.25 find命令 2.26 文件名后缀   find 搜索文件的命令: which   它是从环境变量中找: [root@centos_1 ~]# which ls alias ls='ls --color=auto' /usr/bin/ls   ...
1300 0
|
MySQL 关系型数据库 Shell

热门文章

最新文章