LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-22-2004, 04:38 AM   #1
Gag Halfrunt
LQ Newbie
 
Registered: Nov 2004
Distribution: Mandrake/Knoppix
Posts: 24

Rep: Reputation: 15
grep


So I read the man pages on grep, and tried it out. I opened KWrite, and saved a file to my home dir containing the line 'I like hats'. Then, in bash, I entered 'grep -c hats ~' -- and got 0 results. I tried different arguments, putting the phrase in quotes, all sorts of things. Nothing.

Obviously, I've completely misunderstood what grep is supposed to do. Can anyone enlighten me?
 
Old 11-22-2004, 04:43 AM   #2
Crashed_Again
Senior Member
 
Registered: Dec 2002
Location: Atlantic City, NJ
Distribution: Ubuntu & Arch
Posts: 3,503

Rep: Reputation: 57
If your grepping one file specify it:

# grep hats file.txt

Thats the basic format.
 
Old 11-22-2004, 04:51 AM   #3
Gag Halfrunt
LQ Newbie
 
Registered: Nov 2004
Distribution: Mandrake/Knoppix
Posts: 24

Original Poster
Rep: Reputation: 15
Thanks, that worked fine.

How would I find out which file contained the line "redefines fun" in /mnt/hda1/text?

I appreciate the help. Thanks.
 
Old 11-22-2004, 04:57 AM   #4
ror
Member
 
Registered: May 2004
Distribution: Ubuntu
Posts: 583

Rep: Reputation: 33
grep hats ~/* would have worked
 
Old 11-22-2004, 03:02 PM   #5
Crashed_Again
Senior Member
 
Registered: Dec 2002
Location: Atlantic City, NJ
Distribution: Ubuntu & Arch
Posts: 3,503

Rep: Reputation: 57
Quote:
Originally posted by Gag Halfrunt
Thanks, that worked fine.

How would I find out which file contained the line "redefines fun" in /mnt/hda1/text?

I appreciate the help. Thanks.
# grep 'redefines fun' /mnt/hda1/text

you can also add the -i flag to ignore case.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
grep ?? can grep us variables? DaFrEQ Linux - Software 4 09-14-2005 01:22 PM
help on grep!!!! sanjith11 Programming 5 01-20-2005 06:43 PM
What does rpm -qa |grep th* (as compared to rpm -qa |grep th) display? davidas Linux - Newbie 2 03-18-2004 02:35 AM
"Undeleting" data using grep, but get "grep: memory exhausted" error SammyK Linux - Software 2 03-13-2004 04:11 PM
ps -ef|grep -v root|grep apache<<result maelstrombob Linux - Newbie 1 09-24-2003 12:38 PM


All times are GMT -5. The time now is 04:54 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration