linux - 如何将 find 和 grep 的结果输出为 filename => found
问题描述
如何结合命令的结果find
和grep
格式:filename: => string
?
例如,find . -maxdepth 2 -type f -name .env -exec grep 'CURRENT_ENV' {} \;
该命令将在CURRENT_ENV
找到字符串时向我显示该行,例如CURRENT_ENV=staging
. 我想通过以下方式修改输出:./site1.com: CURRENT_ENV=staging
.
我不明白我怎么能做到这一点。可能吗?
解决方案
-H, --with-filename Print the file name for each match. This is the default when there is more than one file to search.
推荐阅读
- reactjs - 组件在 useEffect 作为 componentDidMount 运行之前渲染了两次
- swift - 使用 Big O 表示法避免多个 forEach 循环的最有效方法
- r - R中带有散点图的数据点的多种颜色
- flutter - Flutter - 如何使用 webview_flutter 包播放 Google Drive 视频预览
- python-3.x - scrapy 获得公告牌前 200 名专辑名称
- firebase - 如何将来自firestore的收集数据存储到列表中?
- java - Androidx 和 YouTubePlayerSupportFragment
- opencv - 在 VS 代码中使用 OpenCV
- r - 如何将参数应用于系数的多模型点和须图?
- html - 我无法用 CSS 修复我的导航栏