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 > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How do you delete multiple text from a comma delimited file dolo21taf Shell Programming and Scripting 1 02-20-2008 05:12 AM
Parsing comma delimited text file chengwei Shell Programming and Scripting 5 02-23-2007 05:38 AM
Searching directory for file that contains some text. LordJezo UNIX for Dummies Questions & Answers 4 04-04-2006 08:58 PM
searching each file in a directory for text jim majors Shell Programming and Scripting 2 03-23-2006 08:29 PM
Help with searching a text file thekid2 Shell Programming and Scripting 6 01-02-2004 02:09 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-27-2007
andyblaylock andyblaylock is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 7
Searching for text in a Space delimited File

Hi

I am trying to search a firewall syslog space delimeted file for all of the different tcp and udp destination ports.
I know that grep will find lines that contain specific text. And I have tried using the the the cut command to cut out of the file certain colums. However the test I am looking for is not always in the same colum.

What I would like to do is search through many log files in a directory for the text string dst_port=*** where the *** would be a wild card so I can see every destination port that has been requested from the firewall logs.
Below is a snap shot of the text im trying to search through.
Any help would be appreciated.
Andy

src=10.217.162.99 dst=10.217.208.105 src_port=4218 dst_port=135 src-xlated ip=10.217.162.99 port=4218 dst-xlated ip=10.217.208.105 po
rt=135 session_id=247646 reason=Close - TCP FIN
  #2 (permalink)  
Old 11-27-2007
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,122
Assuming that a sample log file record is one on ONE line...
one way:
Code:
sed 's/.*dst_port=\([^ ][^ ]*\).*/\1/' myLogFile
P.S. Pls use vB Codes when quoting sample data/source - no line wraps either.
  #3 (permalink)  
Old 11-27-2007
andyblaylock andyblaylock is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 7
Thankyou for your response.
Im presuming that I would need to be in vi to run the search command?
Or can I run this from my regular user prompt?

I have lots of files in one directory so to run vi I would need to consolidate all these files into one big file and run vi on the one consolidated file and complete the search??

Andy
  #4 (permalink)  
Old 11-27-2007
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,122
Quote:
Originally Posted by andyblaylock View Post
Thankyou for your response.
Im presuming that I would need to be in vi to run the search command?
why are you presuming that?
Quote:
Originally Posted by andyblaylock View Post
Or can I run this from my regular user prompt?
yes
Quote:
Originally Posted by andyblaylock View Post

I have lots of files in one directory so to run vi I would need to consolidate all these files into one big file and run vi on the one consolidated file and complete the search??

Andy
I don't understand what 'vi' has to do what you're trying to do...
Copy a sample set of files to a 'sand-box' directory and execute the script on this directory ONLY. Once satisfied with the result - proceed to the 'real' thing.
  #5 (permalink)  
Old 11-27-2007
andyblaylock andyblaylock is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 7
Thankyou,

I did not realize that sed is a stream editor, with my limited knowledge of unix when I viewed your response /s I related that to searching within vi.
Sorry for the confusion, I will give it a shot.

Andy
  #6 (permalink)  
Old 11-27-2007
andyblaylock andyblaylock is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 7
Quote:
Originally Posted by vgersh99 View Post
Assuming that a sample log file record is one on ONE line...
one way:
Code:
sed 's/.*dst_port=\([^ ][^ ]*\).*/\1/' myLogFile
P.S. Pls use vB Codes when quoting sample data/source - no line wraps either.
The above code sed 's/.*dst_port=\([^ ][^ ]*\).*/\1/' myLogFile
, is this the sed command being used with regular expression syntax?
If so what does the s do, I know that / means search
Andy
  #7 (permalink)  
Old 11-27-2007
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,122
no, 's' is short for 'Search'. do 'man sed' to get a full description of the tool's capabilities.
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 01:56 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