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
awk and sed filtering invinzin21 Shell Programming and Scripting 2 01-11-2008 03:56 AM
AIX and cron logs filtering ?: /etc/cronlog.conf, /var/adm/cron/log Keith Johnson AIX 0 01-09-2008 08:32 PM
port filtering ujjwalmohan HP-UX 0 11-26-2007 01:18 AM
awk filtering ? varungupta UNIX for Advanced & Expert Users 4 09-17-2007 02:55 AM
Filtering out data ... videsh77 UNIX for Dummies Questions & Answers 1 12-29-2004 04:59 PM

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 04-08-2008
prvnrk prvnrk is offline
Registered User
  
 

Join Date: Jul 2007
Posts: 138
filtering the logs

Hi,

We are using rsync for syncing remote directories. It is working great along with detailed logs. As the script cron'd and most of the times there're no files to sync we are getting lot of unnecessary log entries and we need to filter them to show only the log entries for the files transferred.

Actual Log: (part of)

2008/04/08 21:43:17 [19631] .d..t.... 09/
2008/04/08 21:43:17 [19631] sent 51 bytes received 26 bytes 1.86 bytes/sec
2008/04/08 21:43:17 [19631] total size is 0 speedup is 0.00
2008/04/08 21:44:49 [5672] building file list
2008/04/08 21:44:49 [5672] done
2008/04/08 21:44:49 [5672] .d..t.... 09/
2008/04/08 21:44:49 [5672] sent 51 bytes received 26 bytes 1.86 bytes/sec
2008/04/08 21:44:49 [5672] total size is 0 speedup is 0.00
2008/04/08 21:46:49 [31047] building file list
2008/04/08 21:46:49 [31047] done
2008/04/08 21:46:49 [31047] .d..t.... 09/
2008/04/08 21:46:49 [31047] <f+++++++ 09/file1.pdf
2008/04/08 21:46:49 [31047] sent 110 bytes received 48 bytes 3.81 bytes/sec
2008/04/08 21:46:49 [31047] total size is 0 speedup is 0.00
2008/04/08 21:48:49 [25274] building file list
2008/04/08 21:48:49 [25274] done
2008/04/08 21:48:49 [25274] .d..t.... 09/
2008/04/08 21:48:49 [25274] sent 71 bytes received 26 bytes 2.40 bytes/sec
2008/04/08 21:48:49 [25274] total size is 0 speedup is 0.00
2008/04/08 21:50:49 [18829] building file list
2008/04/08 21:50:49 [18829] done
2008/04/08 21:50:49 [18829] .d..t.... 09/
2008/04/08 21:50:49 [18829] sent 71 bytes received 26 bytes 2.34 bytes/sec


I achieved the below by using grep:

2008/04/08 21:43:17
2008/04/08 21:43:17 09/
2008/04/08 21:44:49
2008/04/08 21:44:49 09/
2008/04/08 21:46:49
2008/04/08 21:46:49 09/
2008/04/08 21:46:49 09/file1.pdf
2008/04/08 21:48:49
2008/04/08 21:48:49 09/
2008/04/08 21:50:49
2008/04/08 21:50:49 09/
2008/04/08 21:52:49

I need to get only the entries that have a filename (that was actually transferred) as below:

2008/04/08 21:46:49 09/file1.pdf


Thanks
Prvn
  #2 (permalink)  
Old 04-08-2008
in2nix4life's Avatar
in2nix4life in2nix4life is offline
Registered User
  
 

Join Date: Oct 2007
Location: East Coast
Posts: 58
This may work for you if all the filenames being rsynced have the normal three character extension like in your example (file1.pdf):

grep -e '\.[A-Za-z0-9]\{3\}' log

This will allow grep to match anything with a '.' followed by a three character file extension.

Hope this helps.
  #3 (permalink)  
Old 04-08-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
Code:
awk '$3 =~ /\/./'
Might as well run that on the original log, in which case the field would seem to be $5

Last edited by era; 04-08-2008 at 03:12 PM.. Reason: $5 observation
  #4 (permalink)  
Old 04-08-2008
prvnrk prvnrk is offline
Registered User
  
 

Join Date: Jul 2007
Posts: 138
Thank you for your replies.

files may or may not contain extensions. i found solution for this (sorry if did not provide you enough info.) and it is

date1="09"
grep "$date1/" 1.txt |grep -v "$date1/"$


Era - i am getting this below error with your solution.

-sh-3.1# cat 1.txt |awk '$3 =~ /\/./'
awk: $3 =~ /\/./
awk: ^ syntax error
-sh-3.1# cat 1.txt |gawk '$3 =~ /\/./'
gawk: $3 =~ /\/./
gawk: ^ syntax error


Thanks
Prvn
  #5 (permalink)  
Old 04-08-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
Sorry, mixed in some Perl syntax there. Take out the =, it should be just ~ (and take out the Useless Use of Cat too -- google that).
  #6 (permalink)  
Old 04-08-2008
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,509
Code:

awk '
/09\/$/, /done/ {
  for ( i=1;i<=NF;i++ ) {
   if ( $i ~ /<f+++++++/ ) {
      sub("09/","",$(i+1)) 
      print $(i+1)
   }
  }
}' file
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 06:19 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