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
Grepping the last 30 minutes of a log file... jtelep Shell Programming and Scripting 2 03-06-2008 12:27 AM
grepping for period . in file name ? ie grep . bobk544 UNIX for Dummies Questions & Answers 5 12-01-2007 02:31 AM
Loop and grepping into a file skotapal Shell Programming and Scripting 3 08-26-2002 09:28 PM
grepping the first 3 characters from a file rachael UNIX for Dummies Questions & Answers 2 10-15-2001 02:33 PM
grepping the first 3 characters from a file g-e-n-o UNIX for Dummies Questions & Answers 2 10-15-2001 06:11 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 02-04-2007
achararun achararun is offline
Registered User
  
 

Join Date: Dec 2006
Posts: 11
Grepping Errors in a file

Hey All,

I have to grep for an error from a file and get the results of errror in a different file......

But there should be no duplicate entries. Can anyone help me in giving a shell script for this

This is file which contains pattern error which I am supposed to grep and put this in a different file....And this should happen everyday

2007-02-01 23:00:18 Error : this file has error
2007-02-05 24:00:00 date : this afiel ca
2007-02-01 13:00:00 Error : Hi again
2007-02-04 23:00:00 Error : this is again a error
2007-02-04 15:05:00 Error : hi
  #2 (permalink)  
Old 02-04-2007
sb008 sb008 is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2007
Posts: 384
grep ":[0-9][0-9] : Error :" <file1> | cut -c21- | sort -u > <file2>
  #3 (permalink)  
Old 02-05-2007
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,953
Code:
sed -n '/Error/p' currfile | sed 's/\(.*\):\(.*\):\(.*\)/Error :\3/' | sort -u > newfile
  #4 (permalink)  
Old 02-05-2007
anbu23 anbu23 is offline Forum Advisor  
Registered User
  
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,398
Quote:
Originally Posted by matrixmadhan
Code:
sed -n '/Error/p' currfile | sed 's/\(.*\):\(.*\):\(.*\)/Error :\3/' | sort -u > newfile
Code:
sed -n '/Error/s/\(.*\):\(.*\):\(.*\)/Error :\3/p' file
  #5 (permalink)  
Old 02-05-2007
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,953
Oh!

Thats a cool one!

The OP had asked for sorted output and thats why sort -u was included.

Hope that was a typo!
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:23 PM.


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