unix command line ...how to grep and show only file names that contain a string? -


I know I can find a string with this:

  grep -n -d recurse 'Snoopy' * *  

and then it displays each filename and example that contains the string, such as:

  file / name. Txt: 23 Some snip files here: file name 2 test: 59 other snop file / name2.txt: 343 some more snopies etc ...  

The problem is that with many incidents, The list is too large, how can I just show it the actual file name The front, including string, without duplicates and without incident?

Only:

  file / name1.txt file / Name52.txt file / name 28293.txt  

any help Thanks a lot :)

-l flag (or, BSD and GNU does both grep , - file-k-match ) do you want. From

to:

Write only the names of the files that are selected for the standard output, after every file is searched, the path name will be typed. If standard input is searched, POSIX locale will have the pathname of "(standard input)". In other local places, "standard input" can be replaced by some more suitable in those places.

Both BSD and GNU also explicitly guarantee that it will be more efficient (version says, "... grep searches for only one match , Unless a match is found, making searches potentially less expensive ", and" scanning will be closed on the first match. ") T know which grep < / Code> and which options are there, just type man grep on the shell and you want to get the manpage New.


Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -