I am pretty new to Ubuntu I am trying to grasp concepts of finding specific files in directories and in another instance finding specific string or pattern of strings in files. I have read various articles and found command grep and find. Am I on the right track if not please guide me?
grep command is used to search text or searches the given file for lines containing a match to the given strings or words. By default, grep displays the matching lines.
Examples :
grep 'yourword' filename
grep 'yourword' file1 file2 file3
grep 'string1 string2' filename
cat otherfile | grep 'something'
command | grep 'something'
command option1 | grep 'data'
grep --color 'data' fileName
Find Command is one of the most important and much used command in Linux sytems. Find command used to search and locate list of files and directories based on conditions.
Examples :
Find all the files whose name is test.txt in a current working directory.
find . -name test.txt
Find all directories whose name is test in / directory.
find / -type d -name test
Find all the files whose name is test.txt and contains both capital and small letters in /home directory.
find /home -iname test.txt
More Help man grep , man find
Reference Site
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments