How can I recursively find all files in current and subfolders based on wildcard matching?
To recursively search for a pattern, invoke grep with the -r option (or --recursive ). When this option is used grep will search through all files in the specified directory, skipping the symlinks that are encountered recursively.
Try any one of the following commands to see recursive directory listing: ls -R : Use the ls command to get recursive directory listing on Linux. find /dir/ -print : Run the find command to see recursive directory listing in Linux. du -a . : Execute the du command to view recursive directory listing on Unix.
Alternatively referred to as recursive, recurse is a term used to describe the procedure capable of being repeated. For example, when listing files in a Windows command prompt, you can use the dir /s command to recursively list all files in the current directory and any subdirectories.
Using the grep command, we can recursively search all files for a string on a Linux.
Use find for that:
find . -name "foo*"
find
needs a starting point, and the .
(dot) points to the current directory.
Piping find into grep is often more convenient; it gives you the full power of regular expressions for arbitrary wildcard matching.
For example, to find all files with case insensitive string "foo" in the filename:
~$ find . -print | grep -i foo
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With