How to search text pattern in a file in a directory in Linux

preview_player
Показать описание
How to use find command in Linux to search a text in a file in a folder.
find command is very useful and very commonly used command. It has lot of options

Every body will encounter this situation where you have to find some text in some file and you don't know the file name. So the procedure is loop through all the files and grep for the text in each file.

You can do this by one-line shell script using for loop, find, grep commands.

[prompt] $ for file in `find -type f `; do grep -i "text" $file; [ $? -eq 0 ] && echo $file; done;
Рекомендации по теме
welcome to shbcf.ru