- 1 year ago
How to use `shell find` on Make for windows?
To use the shell find
command in a Makefile on Windows, you can utilize the dir
command and the findstr
command together. Here's an example of how you can achieve this:
makefilefind_files:
dir /B /S /A:-D "C:\path\to\search" | findstr /R "pattern"
In the above example, the find_files
target in the Makefile executes the dir
and findstr
commands to search for files matching a specific pattern.
The
dir
command is used with the following options:/B
: Bare format (displays only the path and filename)./S
: Recursively searches subdirectories./A:-D
: Excludes directories from the results.
The output of the
dir
command is then piped (|
) to thefindstr
command, which filters the results based on a regular expression pattern specified with the/R
option. You can modify the"pattern"
part to match the specific pattern you want to search for.
To use this Makefile target, navigate to the directory containing the Makefile using the command prompt or PowerShell, and then run the following command:
shellmake find_files
This will execute the find_files
target, and the output will display the list of files matching the specified pattern in the given directory and its subdirectories.
Note that the above approach uses the Windows command prompt syntax. If you're using a different shell, such as PowerShell, you may need to modify the commands accordingly.