Saturday, 9 March 2019

linux - Using find to find files


If I'm in the root directory, can I use find to search all the directories below it for a file?


I tried find stdio.h but it didn't find anything. However I know that that file is in the filesystem somewhere. How do I find it?



Answer



It's in /usr/include/stdio.h, but for future reference run


$ locate stdio.h

Don't forget to run updatedb first. On Cygwin, you'll want to run it as Administrator.


To look in the current directory and its children:


$ find . -name stdio.h

To look everywhere beneath the root directory:


$ find / -name stdio.h

You tagged this as a Cygwin question, so to search the entire C drive, you could run


$ find /cygdrive/c -name stdio.h

but that's likely to be much slower than searching from an Explorer window.


No comments:

Post a Comment

How can I VLOOKUP in multiple Excel documents?

I am trying to VLOOKUP reference data with around 400 seperate Excel files. Is it possible to do this in a quick way rather than doing it m...