Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am searching for a word, in this case "hehe" that is located in the file findTest

by using grep, but when i initiate the search:

grep -r "hehe"

or

grep -lr "hehe"

it starts but after 5 min waiting nothing happens, even if i am in the same directory as the file. the only way i get a results straight away is being in the same directory and typing:

grep "hehe" findTest 

Are their any other ways to search for a word? even if not in the same directory.

share|improve this question

2 Answers 2

up vote 4 down vote accepted

The grep command expects either a file (or, in the case of -r, directory) name or input from the standard input stream - it's just sitting waiting for you so supply one or the other.

As an alternative to typing the name of the current directory, you can use the shorthand . or ./ i.e.

grep -r "hehe" .

or

grep -r "hehe" ./
share|improve this answer
    
I can see when it searches it finds its path and the word, but when does it stop the search? has been like this for a couple of minuts –  Daniel S. Jun 6 at 21:01
    
@DanielS. If you are having a problem, post the command you ran. If you ran something such as grep -r foo /large-disk-with-a-lot-of-data/* it is going to take a while. –  bodhi.zazen Jun 6 at 21:10
    
hehe yeah that might be the case thanks for the help :) –  Daniel S. Jun 6 at 21:13

Also you can grep into a file with these code that have the same output

grep -i "statement" file.ext
cat file.ext | grep statement
share|improve this answer
    
i get the samme response, No such file or directory –  Daniel S. Jun 6 at 21:04
    
Hey man! you have to replace "file.ext" with your file! –  Rc Ss Jun 6 at 21:09
    
hehe that i know, i have done it :) –  Daniel S. Jun 6 at 21:12

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.