LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > Solaris / OpenSolaris
User Name
Password
Solaris / OpenSolaris This forum is for the discussion of Solaris and OpenSolaris.
General Sun, SunOS and Sparc related questions also go here.

Notices

Reply
 
Search this Thread
Old 03-19-2011, 11:42 PM   #1
type8code0
LQ Newbie
 
Registered: Mar 2011
Posts: 4

Rep: Reputation: 0
egrep read file?


Hi all,

Is it possible for egrep or zcat to read from file?

Example:-

I'm trying to find a few ip addresses in different log files. Problem is the list of ip addresses is quite big. Ip addresses that I use below are just for an example.

Code:
zcat logfile.1.Z logfile.2.Z | egrep 10.10.10.10 10.10.10.11 10.10.10.12 > output
Is it possible to do something like this?

Code:
zcat logfile.1.Z logfile.2.Z | egrep [read from file, let say “iplist”] > output
Code:
zcat logfile.1.Z logfile.2.Z | egrep [iplist] > output
Code:
cat iplist
10.10.10.10
10.10.10.11
10.10.10.12
or

Code:
zcat [read from log files, let say “logs”] | egrep [read from file, let say “iplist”] > output
Code:
zcat [logs] | egrep [iplist] > output
Code:
cat logs
logfile.1.Z 
logfile.2.Z
 
Old 03-20-2011, 12:50 AM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,130

Rep: Reputation: 986Reputation: 986Reputation: 986Reputation: 986Reputation: 986Reputation: 986Reputation: 986Reputation: 986
Have a look at the manpage for grep - while you're at it, check out zgrep.
 
1 members found this post helpful.
Old 03-21-2011, 06:43 AM   #3
type8code0
LQ Newbie
 
Registered: Mar 2011
Posts: 4

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by syg00 View Post
Have a look at the manpage for grep - while you're at it, check out zgrep.
Thanks syg00, unfortunately, zgrep is not install in the system.
Code:
SunOS{type8code0}: grep
Usage: grep -hblcnsviw pattern file . . .

SunOS{type8code0}: whereis grep
grep: /usr/bin/grep

SunOS{type8code0}: zgrep
bash: zgrep: command not found

SunOS{type8code0}: whereis zgrep
zgrep:
 
Old 03-21-2011, 08:05 AM   #4
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,130

Rep: Reputation: 986Reputation: 986Reputation: 986Reputation: 986Reputation: 986Reputation: 986Reputation: 986Reputation: 986
I gave a Linux answer as you posted in a Linux(sub-)forum.
A quick check shows my (old) OpenSolaris guest is broken, so I can't check the commands. Best maybe to request this thread be moved to Solaris (click on the "Report" button on your original post).
 
Old 03-21-2011, 10:58 AM   #5
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,458

Rep: Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941
Moved: This thread is more suitable in Solaris/OpenSolaris and has been moved accordingly to help your thread/question get the exposure it deserves.
 
Old 03-21-2011, 05:49 PM   #6
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946
According to this, Solaris' grep also has the -f "read patterns from file" option.

http://manpages.unixforum.co.uk/man-...-man-page.html
 
1 members found this post helpful.
Old 03-22-2011, 01:23 AM   #7
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,130

Rep: Reputation: 986Reputation: 986Reputation: 986Reputation: 986Reputation: 986Reputation: 986Reputation: 986Reputation: 986
Indeed.
I managed to find a boot environment for my OpenSolaris that works. Being aimed at Linux users it has egrep that I am familiar with, but the xpg4 version does also work the same.
 
  


Reply

Tags
grep, regular expressions, zcat


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
Cat not read a file in linux, even when read permission is enabled DeepSeaNautilus Linux - Software 2 01-16-2011 04:49 PM
Read Only File System? Can't read superblock! haughjd Linux - Software 4 01-15-2008 08:27 AM
web server (fedora core 5) became read-only file system after i upload a file nggs8411 Linux - Server 1 03-26-2007 09:23 AM
how do I make a read-only file NOT read-only? robster Linux - General 1 02-17-2004 09:11 PM
Change from Read only to Read Write File System? justiceisblind Linux - Newbie 3 03-03-2002 07:23 PM


All times are GMT -5. The time now is 08:17 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration