0

I want to search a line of code, which i want to debug, in my current directory. I donot the name of the file which contains the string. I tried this

grep -F "<div id="serv">"

But it doesn't return any result and the cursor just keeps blinking in terminal. The directory has many files so maybe its taking a lot of time for it to execute. Please help.

2 Answers 2

1

This is because of the quotes and because you did not specify where it has to look for. Try this:

grep -F '<div id="serv">' *

or

grep -F '<div id="serv">' /your/dir/*
Sign up to request clarification or add additional context in comments.

4 Comments

* means it will search all the files in the current directory and subdirectories?
* means in this directory. If you want to search in subdirectories, add -r to grep: grep -rF ...
It worked but it is giving the result test/theme.php:echo '<div id="serv">' . "\n";. But there is no test folder in my directory. So what does that mean?
Mmmm it is difficult to say. To know which is the exact file matching, write the full path in grep: grep -F .... /your/dir/*.
0

Using awk

awk '/<div id="serv">/ {print NR,$0,"->",FILENAME}' *

This will search all files for <div id="serv">
If found, print line number, line and filename,

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.