Find a File containing a specific text string in Ubuntu can be done using the grep command.
The format is
grep “text string to search” directory-path
Some Examples
Simple String Search in a directory:
Search for a string called "star wars" in all text files located in /home/movies/*.txt directory, use
$ grep "star wars" /home/movies/*.txt
Search for a string in all files in all contained folders
For this, you can search for a text string all files under each directory, recursively with -r option:
$ grep -r "star wars" /home/movies/
The format is
grep “text string to search” directory-path
Some Examples
Simple String Search in a directory:
Search for a string called "star wars" in all text files located in /home/movies/*.txt directory, use
$ grep "star wars" /home/movies/*.txt
Search for a string in all files in all contained folders
For this, you can search for a text string all files under each directory, recursively with -r option:
$ grep -r "star wars" /home/movies/
No comments:
Post a Comment