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
269 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,841 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,380 points
272 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,380 points
9,381 views
0 votes
0 answers

Linux command to display date in unix format

What command can I use in Linux ...READ MORE

Apr 13 in Linux Administration by Aditya
• 7,660 points
103 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,590 points
5,958 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
29,621 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,830 points
4,775 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
529 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,872 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP