bash - grep -l 'string' path prints the path followed by 'is a directory' -


i have no idea i'm doing wrong. i'm trying grep return string matches in files in directory, instead returning path followed 'is directory'. looked in man pages , did grep --help, not understand syntax.

you need -r recursive.

the following search through some_directory looking files contain something:

grep -l -r some_directory 

if don't specify -r, grep thinks trying search directory , appropriately responds:

grep: some_directory: directory 

with -r, grep understands want files in directory tree starting some_directory.

to retrieve file names without paths

to remove paths file names, can, example, use basename:

grep --null -l -r some_directory | xargs -0 -n1 basename 

if want eliminate some_directory while keeping subdirectories, use:

( cd some_directory; grep -l -r . ) 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -