If you are familiar with Unix-like OS on a regular basis, you probably know it, but some people may not know it, so I will post it. I hope it helps people who are new to the CLI of Linux, WSL, and mac and have trouble finding files.
If you want to search the file name hogehoge
in the range of up to 5 directories, follow the steps below.
$ find . -maxdepth 5 | grep hogehoge
After -maxdepth
, specify the depth of the directory in the range you want to search.
The explanation of -max depth
is excerpted from the Japanese version of man.
-maxdepth levels Searches from the path specified as the command line argument to the directory up to levels down (levels is a non-negative integer). -maxdepth 0 means that only command line arguments are targeted for discriminants and actions.
Furthermore, if the file name is ambiguous, you can add the -i
option to the grep
command.
An example is as follows.
$ find . -maxdepth 5 | grep -i hogehoge
Recommended Posts