How can I recursively find all files in current and subfolders based on wildcard matching?
Use find
:
find . -name "foo*"
find
needs a starting point, so the .
(dot) points to the current directory.
How can I recursively find all files in current and subfolders based on regular expressions
To match whole paths that end in a filename matching a given regular expression, you could prepend .*/
to it, for example .*/f.+1$
. The .*/
should match the path preceding the filename.
Bash - What is a good way to recursively find the type of all files in a directory and its subdirectories?
This may help: How to recursively list subdirectories in Bash without using "find" or "ls" commands?
That said, I modified it to accept user input as follows:
#!/bin/bash
recurse() {
for i in "$1"/*;do
if [ -d "$i" ];then
echo "dir: $i"
recurse "$i"
elif [ -f "$i" ]; then
echo "file: $i"
fi
done
}
recurse $1
If you didn't want the files portion (which it appears you don't) then just remove the elif and line below it. I left it in as the original post had it also. Hope this helps.
Find all files matching pattern in directory and copy subdirectories and files found
You might want to use rsync
instead of find
:
rsync -amv --include='*/' --include='*.xml' --exclude='*' "$DIRECTORY"/ "$OUTPUT_DIRECTORY"
How to ls all the files in the subdirectories using wildcard?
3 solutions :
Simple glob
ls */*.pdb
Recursive using bash
shopt -s globstar
ls **/*.pdb
Recursive using find
find . -type f -name '*.pdb'
Related Topics
How to Send a HTML Email With the Bash Command "Sendmail"
Looping Through the Content of a File in Bash
Use Expect in a Bash Script to Provide a Password to an Ssh Command
Environment Variable Substitution in Sed
How to Debug the Linux Kernel With Gdb and Qemu
How to Know the Script File Name in a Bash Script
The Difference Between Fork(), Vfork(), Exec() and Clone()
How to Create Docker Overlay Network Between Multi Hosts
Why Data and Stack Segments Are Executable
Print a File, Skipping the First X Lines, in Bash
What's the Best Way to Send a Signal to All Members of a Process Group
Using Printf in Assembly Leads to Empty Output When Piping, But Works on the Terminal
How to Print a Number in Assembly Nasm