Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I recursively find all files in current and subfolders based on wildcard matching?

Tags:

linux

shell

How can I recursively find all files in current and subfolders based on wildcard matching?

like image 313
john Avatar asked May 05 '11 23:05

john


People also ask

How do I grep recursively in a directory?

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.

How do I search for a recursive folder?

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.

What is a recursive file search?

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.

Which command is used for search a string recursively in all directories?

Using the grep command, we can recursively search all files for a string on a Linux.


2 Answers

Use find for that:

find . -name "foo*" 

find needs a starting point, and the . (dot) points to the current directory.

like image 90
tux21b Avatar answered Oct 05 '22 03:10

tux21b


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 
like image 31
Paul Whipp Avatar answered Oct 05 '22 03:10

Paul Whipp