开始录制----script -t 2> timing.log -a output.session
退出---exit
播放---scriptreplay timing.log output.session
Find---查找
find . -print
1.根据文件名或正则表达式进行搜索
find /home/sula/Desktop/ -name '*.txt' -print
find . ( -name '*.txt' -o -iname 'test.pdf' ) -print
2.排除匹配到的模式
find . ! -name "*.txt" -print
3.基于目录深度的搜索
find -L /proc -maxdepth 1 -name 'hello.txt' 2> /dev/null
- -L:find命令跟随符号链接
- /proc 从proc目录开始找
- -maxdepth1 将索索范围仅限制在当前目录
- -name ‘hello.txt’ 指定带查找的文件
- 2> /dev/null 将有关循环链接的错误信息发送到空设备中
-mindepth 设置的是find开始进行查找的最小目录深度。
find . -mindepth 2 -name "f*" -print
4.根据文件类型搜索
find . -type d -print
f l d c b s p
普通文件、符号链接、目录、字符设备、块设备、套接字、FIFO
5.根据文件的时间戳进行搜索
-atime(访问错误):用户最近一次访问时间
-mtime(修改时间):文件内容最后一次被修改时间
-ctime(变化时间):文件元数据最后一次被改变的时间(例如:权限or所有权)
eg:以天为单位
find . -type f -atime -7 -print---7天内被访问过的所有文件
find . -type f -atime 7 -print---恰好在7天前辈访问过的所有文件
find . -type f -atime +7 -print---打印出访问时间超过7天的所有文件
eg:以分钟为单位
-amin
-mmin
-cmin
-newer----找出比参考文件更新的(更近的修改时间)所有文件
eg:find . -type f -newer file.txt -print
总结:find命令的时间戳处理选项有助于编写系统备份和维护脚本
6.基于文件大小的搜索
find . -type f -size +2k
find . -type f -size -2k
find . -type f -size 2k
k---可以换成b c w k M G
分别为:块(512字节)、c(字节)、w(字-2字节)、k(1024字节)、M(兆字节1024K)、吉字节(1024M字节)。
7.基于文件权限和所有权的匹配
find . -type f -perm 644 -print
-perm选项指明find应该只匹配具有特定权限值的文件
-user USER 就能够找出由于某个特定用户所用有的文件
USER可以是用户名和UID
8.利用find执行相应操作
①删除匹配的文件
find . -type f -name "*.swp" -delete
②执行命令-exec
find . -type f -user root -exec chown slynux {} ;
{}:代表文件名
; 转义后变为chown命令的结束
9.让find跳过特定的目录
修剪:在搜索时排除某些文件或目录的技巧叫做修剪。
-prune排除某些符合条件的文件:
find devel/source_path -name '*.git' -prune -o -type f -print