The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Urgent: find some strings in all the tables unknown123 Shell Programming and Scripting 1 09-12-2008 06:46 AM
Find lines with space between strings Galt Shell Programming and Scripting 5 05-07-2008 02:06 PM
Find information from complicated strings lalelle Shell Programming and Scripting 9 02-12-2008 11:28 AM
To find multiple strings count in a file salaathi Linux 3 11-28-2007 06:31 AM
Using grep to find strings of certain lengths? crabtruck UNIX for Dummies Questions & Answers 4 11-04-2003 06:25 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-04-2008
thepurple thepurple is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 134
Find Strings in Files

experts,

i am using solaris 9. there are serveral *.log files in a directory "/var/alllogs/". Among the files one or several files contain the string "0198634873".

I want do-

cat *.log | grep "0198634873"; And want to see which Files(file_name) contain that string. Plus output will go to a file.

guys could you please help me how to write the script.

//purple
  #2 (permalink)  
Old 10-04-2008
Habitual's Avatar
Habitual Habitual is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 22
grep 0198634873 /var/alllogs/

will show the hits.
  #3 (permalink)  
Old 10-04-2008
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,717
grep -l will list the filenames without showing the matched lines, only matching filenames.

Code:
grep -l 'pattern to match goes here' /var/allogs/*.log
  #4 (permalink)  
Old 10-04-2008
Bijayant Kumar Bijayant Kumar is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 19
Quote:
Originally Posted by jim mcnamara View Post
grep -l will list the filenames without showing the matched lines, only matching filenames.

Code:
grep -l 'pattern to match goes here' /var/allogs/*.log
And if you need output to the file at the same time then
grep -l 'pattern to match goes here' /var/allogs/*.log | tee output.txt
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




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


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0