LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
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 04-30-2007, 10:01 AM   #1
shadowdancer
Member
 
Registered: Jan 2007
Location: Indonesia
Distribution: openSUSE, Slackware, Now Debian, and now again: Ubuntu
Posts: 61

Rep: Reputation: 15
Find text inside files and formatting


Hello everybody,

I know a very useful command,that is:
Code:
$grep -lir "sometext" *
that will find "sometext" inside files in current directory and in all subdirectory. But, the output is only the files.

How to make it something like this:

Code:
/data/thisfilecontaintext.txt
sometext is inside this file
/data/anotherfile
i want to search for sometext
Basically, I want the output to print not only the file, but the whole line containing the text I search.

Any comments will be really appreciated.

Best Regards.
 
Old 04-30-2007, 10:06 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 11,596

Rep: Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520
Remove the "l" option:
Code:
grep -ir "sometext" *
 
Old 05-02-2007, 01:56 PM   #3
shadowdancer
Member
 
Registered: Jan 2007
Location: Indonesia
Distribution: openSUSE, Slackware, Now Debian, and now again: Ubuntu
Posts: 61

Original Poster
Rep: Reputation: 15
Woo..

Works like a charm!

Thank you very much
 
  


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
shell scripting: "formatting" issue with text files eur0dad Programming 3 08-17-2006 11:50 AM
Search for text inside files alaios Linux - Newbie 7 03-12-2006 10:20 AM
searching inside text files minm Linux - Newbie 2 01-09-2005 12:56 AM
linux 'find' to find text files subu_s Programming 2 12-02-2004 03:56 AM
how to convert windows formatted text files to *nix formatting? zero79 Linux - General 8 06-11-2004 04:00 AM


All times are GMT -5. The time now is 09:00 PM.

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