How can I combine the result of commands find
and grep
in the format: filename: => string
?
For example, find . -maxdepth 2 -type f -name .env -exec grep 'CURRENT_ENV' {} \\;
find . -maxdepth 2 -type f -name .env -exec grep 'CURRENT_ENV' {} \\;
The command will display me the line when CURRENT_ENV
string found, eg CURRENT_ENV=staging
. I want to modify the output in the follow way: ./site1.com: CURRENT_ENV=staging
.
I can't understand How can I reach that. Is it possible?
-H, --with-filename Print the file name for each match. This is the default when there is more than one file to search.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.