GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Select-String's wildcard matching for -Path should exclude directories · Issue #4820 · PowerShell/PowerShell

Select-String's wildcard matching for -Path should exclude directories #4820

New issue
Copy link
New issue
Copy link
Closed
Closed
Select-String's wildcard matching for -Path should exclude directories#4820
Copy link
Assignees
iSazonov
Labels
Issue-BugIssue has been identified as a bug in the productIssue has been identified as a bug in the productResolution-FixedThe issue is fixed.The issue is fixed.WG-Cmdletsgeneral cmdlet issuesgeneral cmdlet issues

Description

@mklement0
Michael Klement (mklement0)
opened on Sep 12, 2017
Issue body actions

Select-String only supports file paths passed to -LiteralPath and (in resolved form) -Path.

As an aside: Even though the error message when you pass a directory path is technically correct, it could be more helpful:

Select-String: The file /path/to/dir cannot be read: Access to the path '/path/to/dir' is denied.

It would be convenient to automatically exclude directory matches from what a wildcard expression passed to -Path resolves to, given that they won't be processed anyway.

This would allow searching all files in a directory, whatever extension they have or whether they have one at all, with Select-String -Path * findme

On a side note: -Path's wildcard matching currently invariably excludes hidden files, so the only way to include hidden files in the search is to pipe from Get-Item / Get-ChildItem with -Force.

Current behavior

Setup: Create a directory that contains a subdirectory and a text file:

Push-Location (New-Item -Type Directory -Force (Join-Path ([io.path]::GetTempPath()) $PID))
$null = New-Item -Type Directory subd
'hi' > t.txt

Using wildcard expression * reports an error, because * also matches the directory, subd:

> Select-String -Path * hi
Select-String : The file .../subd cannot be read: Access to the path '.../subd' is denied.
...

t.txt:1:hi

Desired behavior

The directory wildcard match should be ignored.

> Select-String -Path * hi

t.txt:1:hi

Environment data

PowerShell Core v6.0.0-beta.6 on macOS 10.12.6
PowerShell Core v6.0.0-beta.6 on Ubuntu 16.04.3 LTS
PowerShell Core v6.0.0-beta.6 on Microsoft Windows 10 Pro (64-bit; v10.0.15063)
Windows PowerShell v5.1.15063.502 on Microsoft Windows 10 Pro (64-bit; v10.0.15063)

Activity

  1. Ilya (iSazonov)
    added
    Area-Cmdlets-Utility
    Issue-BugIssue has been identified as a bug in the productIssue has been identified as a bug in the product
    on Sep 13, 2017
  2. Ilya (iSazonov)
    self-assigned this
    on Sep 13, 2017
  3. Dongbo Wang (daxian-dbw)
    closed this as completedin #4829on Sep 14, 2017
  4. Ilya (iSazonov)
    added
    Resolution-FixedThe issue is fixed.The issue is fixed.
    on Sep 15, 2017
  5. iSazonov commented on Sep 15, 2017

    @iSazonov
    Ilya (iSazonov)
    on Sep 15, 2017
    Collaborator
    More actions

    Michael Klement (@mklement0) I close ONE from tons your Issues 😄

  6. mklement0 commented on Sep 15, 2017

    @mklement0
    Michael Klement (mklement0)
    on Sep 15, 2017
    ContributorAuthor
    More actions

    Ilya (@iSazonov): 😁 - I appreciate it.

  7. Ryan Yates (kilasuit)
    added
    WG-Cmdletsgeneral cmdlet issuesgeneral cmdlet issues
    and removed
    WG-Cmdlets-Utility
    on Jul 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @iSazonov
    Ilya (iSazonov)

Labels

Issue-BugIssue has been identified as a bug in the productIssue has been identified as a bug in the productResolution-FixedThe issue is fixed.The issue is fixed.WG-Cmdletsgeneral cmdlet issuesgeneral cmdlet issues

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402520 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.