LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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, 09: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, 09:06 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Remove the "l" option:
Code:
grep -ir "sometext" *
 
Old 05-02-2007, 12: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



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:43 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
Open Source Consulting | Domain Registration