find: paths must precede expression

Author - Webner

In Linux bash you may face an error while using wildcard * to search files. For e.g. trying to search all jar files with the following command:

find. -name *.jar

will give following error:

find: paths must precede expression

Usage: find [-H] [-L] [-P] [path…] [expression]

Reason is that * is interpreted by shell itself before arguments are passed to find command. * will resolve to all folders and files within current folder, hence does not make much sense with .jar extension at the end. For this reason we need to escape * somehow so that it goes to find command as it is, without expanded by shell. There are 2 ways that I know:

find . -name *.jar

second is

find . -name ‘*.jar’

Free Online Courses with Certificate
Free Online Courses With Personalized Certificate
Study online, from the comfort of your home
Study online, from the comfort of your home

Webner Solutions is a Software Development company focused on developing Insurance Agency Management Systems, Learning Management Systems and Salesforce apps. Contact us at for your Insurance, eLearning and Salesforce applications.

Leave a Reply

Your email address will not be published.