Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the double asterisks mean?

Tags:

powershell

I often see PowerShell commands that use paths that use a double asterisks:

Copy-Item c:\source\** d:\target

The example may be wrong, as I don't understand POSH that well yet. But I do see examples using the ** in paths. What does it mean?

like image 465
Greg McGuffey Avatar asked Nov 15 '16 21:11

Greg McGuffey


1 Answers

Actually, I believe the above answer is wrong.

Assume we have the following directory structure:

dbl_wc (top level) --one_level_in --aa.txt --one_level_in1 --bb.txt --deeper_dir --abc.txt

Copy-Item .\dbl_wc\**\*.txt copy_target -Force Will only look for *.txt in any directory under .\dbl_wc. And it won't look in sub-directories (so for example .\dbl_wc\one_level_in1\deeper_dir). So it will get both aa.txt and bb.txt, but not abc.txt. It would also not get any .txt file directly under dbl_wc

Essentially, the ** stands for a directory-wildcard, but not recursive.

EDIT: just tested it with *, and it does the same thing (so Copy-Item .\dbl_wc\*\*.txt copy_target -Force does the exact same thing as above)

like image 74
information_interchange Avatar answered Sep 28 '22 04:09

information_interchange