Interview Q&A / Linux & Shell
Linux & Shell interview questions
Permissions, processes, pipes and the commands you are expected to know cold.
Prefer rapid revision? Practise Linux & Shell short interview answers →
- How do you search for text and files in Linux using grep and find?
grep searches inside files for lines matching a pattern, for example grep -rn "error" logs/. find searches the directory tree for files by name, type, size or age, for example find . -name "*.log" -mtime -1. They are often combined to search text inside a chosen set of files.
BeginnerIn-depth2 min read - What do the grep options -i, -v, -c, -n and -w do?
-i ignores case, -v inverts the match to show non-matching lines, -c prints only a count of matching lines, -n adds line numbers and -w matches whole words only. They combine, so grep -ivn error file works.
BeginnerQuick answer1 min read