Solved

search for data within files in linux

Posted on 2014-03-07
4
464 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
  • 2
4 Comments
 
LVL 31

Accepted Solution

by:
farzanj earned 250 total points
Comment Utility
Try:

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

Open in new window

0
 
LVL 1

Author Comment

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

Expert Comment

by:farzanj
Comment Utility
Yes,
grep -l

lower case L option
0
 
LVL 76

Assisted Solution

by:arnold
arnold earned 250 total points
Comment Utility
-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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now