grep - 为什么 grep 无法在文件中找到模式
问题描述
我在尝试
grep -rn '*.cpp' -e 'aPattern'
aPattern
在包含 cpp 文件的目录中递归查找模式,但我得到了
*.cpp no such file or directory
为什么会失败?子目录中有cpp文件
解决方案
找到了解决办法
grep -rn --include '*.hpp' -e 'aPattern'
关键是放--include
更好
grep --color -rn --include '*.hpp' -e 'aPattern'
推荐阅读
- css - nuxt.config.js (Nuxt) 中的内联字体声明
- angular - main.js 文件大小太大 - 带有单个 SPA 的微前端
- google-bigquery - 执行 SA360 <> BigQuery 数据传输服务后,广告客户未显示在转化报告中
- python - 语音识别无法识别我的声音
- docker - 节点容器无法连接到 Ubuntu 21.04 上的 MariaDB 容器
- ruby - Ruby - 语法错误,意外的 tIDENTIFIER,期待结束
- angular - 每个项目的组件“应该创建”测试都失败,并出现错误“无法将 @Input 装饰器与查询装饰器结合起来”
- jmx - Apache Artemis listMessages MBean 操作始终不返回任何内容
- python-3.x - 如何在 AWS Glue 作业 ETL 中定义具有外键关系的 ETL 脚本
- amazon-web-services - 使用Nginx反向代理访问amazon polly