powershell - Confused with -Include parameter of the Get-ChildItem cmdlet -
From the documentation:
- Include
Only specified items is not. The value of this parameter passes the path parameter. Enter path element or pattern, such as "* .txt" wildcard is allowed
The included parameter is effective only if the command contains the riser parameter or the path goes to the contents of a directory, such as That C: \ Windows *, where Wildcard specifies the content of the letter C: \ Windows directory.
My first understanding was:
c: \ test \ a.txt c: \ test \ b.txt To write 'a.txt' and 'b.txt' I can write:
gc-path "c: \ test \ *" -index "* .txt " And it works. But now consider such a hierarchy:
c: \ test \ a.txt c: \ test \ b.txt c: \ test \ c.txt \ c.txt The same command returns: a.txt, b.txt, c.txt
The actual argument seems:
- to include All the entities specified by the included -path used to have a file if it matches - return it if the matching element is a folder, look inside and match the children of the first level. Apart from this, the documentation says:
The parameters included are effective only when the order contains the Rickers parameter or the path of the contents of a directory It goes ...
This is also wrong. EG
GC-path "C: \ test" - "" * .txt "-It returns nothing without, without - I get the folder contents. So- contains definitely "effective" is what really happens here? -Specify the "c: \ test" path, and the in-in tries to match this path. Like "* .txt" does not match "test", so nothing returns, but see:
gc-path "c: \ test" -index "* t "This one. Txt returns b.txt and "* T" matches as CTTX matches "test" and all child items.
After all, even knowing that how it works now, I do not understand when to use it, why should I see it inside the subfolder? Why should it be so complicated?
You are confused in using - Include - The flag on the flag is applied to the path, Not the contents of the path. Without the use of the recurring flag, the path that is in question is the one you specified. This is the reason that after all the work you did, there is a T in path near path C: \ Test and therefore match "* t" .
You can verify it by trying
gci-path "c: \ test" -in * e * < P> It will still produce all the children in the directory, yet none of their names match. The reason for this is that it is more effective with the Excluded parameters that you will see the wildcard hierarchy
Comments
Post a Comment