Recall & Review
beginner
What does the
-r option do in the grep command?The
-r option tells grep to search recursively through all files in the specified directory and its subdirectories.Click to reveal answer
beginner
How would you use
grep -r to find the word "apple" in all files inside the current directory and its subfolders?You would run:
grep -r "apple" . where . means the current directory.Click to reveal answer
beginner
True or False:
grep -r searches only text files by default.False.
grep -r searches all files, including binary files, unless you add options to exclude them.Click to reveal answer
intermediate
What is the difference between
grep -r and grep -R?grep -r follows symbolic links only if they are on the command line, while grep -R follows all symbolic links recursively.Click to reveal answer
intermediate
How can you limit
grep -r to search only files with a specific extension, like .txt?You can combine
grep -r with --include="*.txt" like this: grep -r --include="*.txt" "pattern" .Click to reveal answer
What does the command
grep -r 'hello' /home/user do?✗ Incorrect
-r means recursive search through all files and folders inside the given directory.Which option makes
grep follow all symbolic links recursively?✗ Incorrect
-R follows all symbolic links recursively, unlike -r.How do you search recursively for the word 'error' only in files ending with '.log'?
✗ Incorrect
Use
--include='*.log' with -r to limit search to .log files.True or False:
grep -r will skip binary files by default.✗ Incorrect
grep -r searches all files including binary unless told otherwise.What symbol represents the current directory when using
grep -r?✗ Incorrect
The dot
. means the current directory in Linux commands.Explain how to use
grep -r to find a word inside all files in a folder and its subfolders.Think about how to tell grep to look inside folders and subfolders.
You got /4 concepts.
Describe the difference between
grep -r and grep -R regarding symbolic links.Consider how each option treats links to other files or folders.
You got /3 concepts.