find grep strings 命令

语法: find [path] [options] [tests] [actions]
[path] 可以传递多个参数, 如: /usr /home …
[options] 常用的选项如下:
-depth: search the content of a directory before looking at the directory itself
-follow: follow symbolic links
-maxdepths N: search at most N levels of the directory
-mount (or -xdev): don’t search directories on other file systems
[tests] 表示查找的时候所用的测试条件, 常用的如下:
-atime N: the file was last accessed N days ago
-mtime N: the file was last modified N days ago
-name pattern: the pattern of the file, must always in quotes
-newer otherfile: the file is newer than the file “otherfile”
-type C: C could be any particular type, “d” is for directory, “f” is normal file
-user username: the file which owned by the username
还可以使用逻辑运算符, 比如: ! 或者-not, -a或者-and, -o或者-or, 前者是短符号, 后者是长符号.
在用的时候要用括号(), 同时括号()需要转义, 例如: (-newer X -or -name “_*” )
[actions] 可以在找到文件后执行操作, 常用的有:
-exec command: this action must end with \;
-ok command: this action must end with \; it will ask for user confirm before execute the command
-print: print out the name of file
-ls: use ls command on file

同样有用的命令是 grep
grep [options] pattern [files]
[options]
-c: rather than print matching lines, print out a count of the number of lines that match
-E: turn on extended expressions
-h: suppress the normal prefixing of each output line with the name of the file it was founded in
-i: ignore case
-l: list the name of files with matching lines, don’t output the actual matched line
-v: invert the matching option to select non-matching lines

正则表达式:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值