Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to only mark file not folder using glob pattern?

Consider the following file structure:

root
   |- folder1
   |- folder2
   |- folderN
   |- file1
   |- file2
   |- fileN

How to target only files without excluding (!) each folder one by one?

like image 451
Handsome Nerd Avatar asked Feb 03 '26 03:02

Handsome Nerd


1 Answers

So you just want the files in that certain root directory, without the folders and contents of those folders.

The glob you are looking for is *. This one selects all the files inside the directory you are currently. Or use root/* if you want to select all the files inside the root folder without its subfolders. To select subfolders and subfolder content, you have to use the Globstar: **

You can test your glob easily here:

like image 135
ddprrt Avatar answered Feb 05 '26 03:02

ddprrt