Grep file search returns: Is a directory in OSX Mountain Lion -


i trying search specific file using example how use grep command search file?

trying grep searchingforfile /users/myuser/path/to/dir returns:

grep: /users/myuser/path/to/dir: directory

please let me know best way search file in case.

if want find files begin f in current directory:

ls f* 

if want find files ending "jpg" in current directory , directories below:

find . -type f -name "*.jpg" -print 

if want filenames containing pattern in current directory , below:

find . -type f -name "pattern" -print 

but put asterisk either side of pattern (i can't on here)

or, if pattern more complicated

find . -type f -print | grep "somefunkypattern" 

if want search pattern in file called fred:

grep pattern fred 

if want search bill or steve in files called friends1 , friends2 , don't care case (capital letters) use -i option:

egrep -i "steve|fred" friends1 friends2 

if want search mike in files names start "friend*":

grep mike friend* 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -