Linux Using grep to display filenames

0 votes

Is there any way I can use grep just to show the filenames and not anything else. I'm trying this:

find . -iname "*php" -exec grep -H myString {} \;

Do I have to use xargs cause I cannot find anything related to grep to do this?

May 24, 2019 in Linux Administration by Damon Salvatore
• 5,980 points
183 views

1 answer to this question.

0 votes

You need t use -l flag with grep(lowercase L). From Unix Docs:

-l
    (The letter ell.) Write only the names of files containing selected
    lines to standard output. Pathnames are written once per file searched.
    If the standard input is searched, a pathname of (standard input) will
    be written, in the POSIX locale. In other locales, standard input may be
    replaced by something more appropriate in those locales.
answered May 24, 2019 by ajs3033
• 7,280 points

Related Questions In Linux Administration

0 votes
1 answer

To attach a file using mail command on Linux

$ echo | mutt -a syslogs.tar.gz admin@domain.org READ MORE

answered Jun 28, 2019 in Linux Administration by Upasana
• 8,620 points
1,333 views
0 votes
1 answer

How to display available interfaces in Linux system?

Hi@akhtar, You can use tcpdump command in your ...READ MORE

answered Oct 4, 2020 in Linux Administration by MD
• 95,320 points
116 views
0 votes
1 answer

How to display captured packets in HEX and ASCII in Linux?

Hi@akhtar, To display the packet value you can ...READ MORE

answered Oct 4, 2020 in Linux Administration by MD
• 95,320 points
1,304 views
0 votes
1 answer

How to display a simple list of all disks, like this /dev/sda /dev/sdb ?

You can list all the disk in ...READ MORE

answered Jul 12, 2018 in Linux Administration by DearestOne
• 200 points
3,109 views
+1 vote
1 answer

Unable to access Jenkins. I newly installed Jenkins but for some reason I cannot access it.

Try changing the port, Change JENKINS_AJP_PORT="xyz" to JENKINS_AJP_PORT="abc" If changing the ...READ MORE

answered Jul 4, 2018 in Jenkins by Sophie may
• 10,550 points
3,878 views
0 votes
2 answers

How do I find all files containing specific text on Linux?

grep -rnw 'text to find recursively inside ...READ MORE

answered May 20, 2019 in Linux Administration by Ritesh Singh
20,966 views
0 votes
1 answer
0 votes
1 answer

Grep across multiple files in Hadoop

You are looking to applying to grep ...READ MORE

answered Jan 8, 2019 by Frankie
• 9,810 points
4,644 views
0 votes
1 answer

How to send mail using linux shell script?

If you've already configured the server, with ...READ MORE

answered Jun 11, 2019 in Linux Administration by ajs3033
• 7,280 points
276 views
0 votes
2 answers

how to loop through the content of a file using bash

#!/bin/bash for i in  `cat peptides.txt` do echo $i done READ MORE

answered Sep 5, 2020 in Linux Administration by Prakash K. Aithal
1,488 views