string-in-file-search

在指定目下寻找包含指定字符串的文件:

  1. 输出文件名和内容
1
grep mysqli_connect ./

其中,,

  • 加入-r可以递归搜索

  • 加入-l可以只打印匹配的文件名

  • 加入参数-e可以支持正则表达式

  • 加入参数-i可以不区分大小写

  • 加入参数-c可以指定匹配的行数

  • 加入-v可以查出不匹配指定字符串的行数

  1. 替换上述匹配命令中的匹配字符串

    1
    sed -i "s/mysqli_connect/mysql_connect/g" `grep mysqli_connect -rl ./`

    其中,-i表示替换立即生效

作者

彭凯

发布于

2021-08-08

更新于

2021-08-08

许可协议

You need to set install_url to use ShareThis. Please set it in _config.yml.
You forgot to set the business or currency_code for Paypal. Please set it in _config.yml.

评论

You forgot to set the shortname for Disqus. Please set it in _config.yml.