Solved

search for data within files in linux

Posted on 2014-03-07
4
477 Views
Last Modified: 2014-03-07
hello there,
I would like to know how can I search only .php files using a command like this

grep -r -i "cHRVa2RQVjNSb1YwVndi" * | cut -d: -f1


I tried using this, and it works but doesnt show file path
find . -name '*.php' -exec grep "RnBOYms1d1V6Rk9jMDR3VG" {} \;
0
Comment
Question by:XK8ER
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 31

Accepted Solution

by:
farzanj earned 250 total points
ID: 39914155
Try:

find . -name '*.php' -exec grep -H "RnBOYms1d1V6Rk9jMDR3VG" {} \;

Open in new window

0
 
LVL 1

Author Comment

by:XK8ER
ID: 39914159
any way to only display the file and not data?
0
 
LVL 31

Expert Comment

by:farzanj
ID: 39914163
Yes,
grep -l

lower case L option
0
 
LVL 78

Assisted Solution

by:arnold
arnold earned 250 total points
ID: 39914168
-l is the flag for grep to return the filename where the pattern exists.

What do you need to do with this?

It might be simpler if you provide details on what it is you wanto achieve.

Do you need to to replace the pattern with a new pattern?

perl -pi.bak -e 's/pattern/replacement/g;' *

 test on a single file first.  Files where the match is made will be duplicated with a .bak suffix.
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question