Monday, April 29, 2024
 Popular · Latest · Hot · Upcoming
1
rated 0 times [  1] [ 0]  / answers: 1 / hits: 5718  / 2 Years ago, fri, may 6, 2022, 4:52:20

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?


More From » search

 Answers
4

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


[#26639] Friday, May 6, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
lishrag

Total Points: 306
Total Questions: 109
Total Answers: 125

Location: Saint Lucia
Member since Wed, Feb 8, 2023
1 Year ago
;