Skip to content

In Linux, Find Command Fails Even With Quoted and Escaped Asterisk #4680

@bigboy-pdb-spam

Description

@bigboy-pdb-spam

Steps to reproduce

PS> touch ab.txt 'a b.txt'

# Question mark character works

PS> find -name 'a?.txt'
ab.txt

PS> find -name 'a??.txt'
a b.txt

# Asterisk appears to be being expanded into file names

PS> find -name 'a*b.txt'
/usr/bin/find: paths must precede expression: ab.txt
Usage: /usr/bin/find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec|time] [path...] [expression]

# Escaping asterisk doesn't work

PS> find -name 'a`*b.txt'
# No output, which indicates the parameters were accepted, but the search produced no results.

Expected behavior

PS> find -name 'a*b.txt'
./ab.txt
./a b.txt

Actual behavior

PS> find -name 'a*b.txt'
/usr/bin/find: paths must precede expression: ab.txt
Usage: /usr/bin/find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec|time] [path...] [expression]

It appears that the command is being converted into: find -name 'a b.txt' 'ab.txt'

Environment data

> $PSVersionTable
Name                           Value                                           
----                           -----                                           
PSVersion                      6.0.0-beta                                      
PSEdition                      Core                                            
GitCommitId                    v6.0.0-beta.6                                   
OS                             Linux 4.4.0-92-generic #115-Ubuntu SMP Thu Au...
Platform                       Unix                                            
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                         
PSRemotingProtocolVersion      2.3                                             
SerializationVersion           1.1.0.1                                         
WSManStackVersion              3.0 

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions