Linux

Finding & Searching Files

21 flashcards · answers and spaced-repetition review in the KnowCard app

You need to locate a program's binary plus its man page and config files, not just the executable that PATH would run. Why does which fall short here, and what covers the wider set?
A colleague says locate is fast because it has an optimized filesystem-walk. What is actually the source of its speed, and what is the cost of that design?
On a modern system locate is provided by the plocate package rather than the classic tool. Where does plocate keep its database, and how do you control which directories get indexed?
When would you reach for find over locate even though find is much slower, and what does find return if you give it no search criteria?
In find, how do -mtime -5, -mtime +5, and -mtime 5 differ, and when would you switch to -ctime instead?
You want find to return only directories under /etc, and separately to list files owned by the users group that changed in the last five days. How do you express each, and what does -type d exclude?
With grep, a teammate assumes -c prints the total number of times the pattern appears in a file. What does -c actually count, and what does -v do?
Why does grep pattern *.tex miss matches that find -name '*.tex' -exec grep can catch, and how does the find form recurse?
which locates emacs instantly but returns nothing for a system command you know is installed. Why does an ordinary user hit this, and what resolves it?
locate can't find a file you created an hour ago. What actually refreshes its results, and what does forcing that refresh require?
The locate command behaves the same across distributions, but the package behind it and where its database lives differ. How does openSUSE's implementation differ from the plocate used elsewhere?
You want only the .tex files that sit under a directory named latex, not every .tex on the disk. Which find test matches against the directory path rather than just the filename?
rm $(find . -name '*~') deletes backups fine on a small tree but throws an error on a large one. What fails, and what's the correct approach?
You build a find -exec grep -q command to print the names of files whose contents match, but the -print behaves wrong. What ordering rule governs -print with -exec?
During a recursive content grep you want to skip large binary files. Which find test filters by size, and how do you read a value like -10k?
Beyond running it as a standalone command, how does fzf hook into the shell for on-the-fly completions and history search?
You can't tell which file under /etc mentions a setting, and you need to match file contents, not filenames, ignoring case. Which command does that recursively?
Why is a glob like .* dangerous when acting on hidden files, and what reliably lists just the hidden files in the current directory?
Your comment-stripping filter must reject lines beginning with either # or ; in a single grep pass. What does the -E option enable, and how do you express "either/or"?
grep -v '^#' cleans most comments out of a config file but a few comment lines survive. Which comments slip through, and how do you catch them?
What does running fzf with no arguments do, and how do you hand your chosen file to another program?

Start learning today

Free to start — download the app or use it in your browser.

Get it on App StoreGet it on Google Play