标签:linux
grep :查看文本文件内容,显示包含指定“字符串”的行。
格式:grep [选项] ‘匹配字符串’ 文本文件
例: grep ‘ root‘ /etc/passwd
grep -i ‘Root‘ /etc/passwd 忽略大小写
grep -v ‘root‘ /etc/passwd 取反,不包含
grep ‘^root‘ /etc/passwd 以字符串root开头
grep ‘root$‘ /etc/passwd 以字符串root结尾
grep -v ‘^$‘ /etc/passwd 去除空行的显示
find:按条件查找
根据预设的条件递归查找对应文件
格式: find [目录] [条件]
常用条件表示:
-type类型(f文件,d目录,l快捷方式)
-name "文档名称"
-size + 文件大小(k,M,G)
-user 用户名
例:find /boot -type f
find /boot -name "passwd"
find /boot -name "install*" -type d
find /boot -name "*.txt" -type f -size + 10M
使用find命令的-exec操作
格式:find -exec 处理命令 {} \;
例: find / -user xixi -type f -exec cp -r {}/root/ \;
找到根下的用户xixi文件复制到/root下
cat 适合查看内容较少
less 适合查看内容较多的
head -n 看头几行
tail -n 看尾几行
正则表达式:用描述的语言去表达心中所想。
标签:linux
原文地址:http://13399294.blog.51cto.com/13389294/1980135