The UNIX Forums  



Go Back   The UNIX Forums > Top Forums > Shell Programming and Scripting
Home Forums Register Rules & FAQDonate Members List Search Today's Posts Mark Forums Read

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

Reply
 
Submit Tools Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 1 Week Ago
spt spt is offline
Registered User
 
Join Date: May 2008
Posts: 1
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
compare files

Hey scripters

this is the first time i use AWK
i looked for a solution to find out who is "out" at the moment
i get a log in this format

Code:
time (user) OUT: "DOORS" mail1  [ttt] 
time (user) OUT: "DOORS" mail2  [ttt] 
time (user) IN: "DOORS" mail2  [ttt] 
time (user) OUT: "DOORS" mail2  [ttt] 
time (user) OUT: "DOORS" mail3  [ttt] 
time (user) OUT: "DOORS" mail4  [ttt] 
time (user) IN: "DOORS" mail3  [ttt] 
time (user) IN: "DOORS" mail4  [ttt]
if i analyze this log manually, i can find out that mail1 and mail2 are out at the moment

with awk command $3=="IN:" {print $0} and $3=="OUT:" {print $0} i have split the log into two files "in.txt" and "out.txt" with

content of in.txt
Code:
time (user) IN: "DOORS" mail2  [ttt] 
time (user) IN: "DOORS" mail3  [ttt] 
time (user) IN: "DOORS" mail4  [ttt]
content of out.txt
Code:
time (user) OUT: "DOORS" mail1  [ttt] 
time (user) OUT: "DOORS" mail2  [ttt] 
time (user) OUT: "DOORS" mail2  [ttt] 
time (user) OUT: "DOORS" mail3  [ttt] 
time (user) OUT: "DOORS" mail4  [ttt]
now i need help by comparing these two files who is out at the moment.

my wanted output is wo is out at the moment
Code:
time (user) OUT: "DOORS" mail1  [ttt] 
time (user) OUT: "DOORS" mail2  [ttt]
any help is appreciated
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 1 Week Ago
...@...
 
Join Date: Feb 2004
Location: NM
Posts: 3,030
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
Code:
grep 'OUT:' logfile | sort -u -k5.1,5.8 | awk '{ print $5}'
logfile is the output you show first - skip all the other steps.
Reply With Quote
Forum Sponsor
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
compare two files charandevu Shell Programming and Scripting 7 03-30-2008 02:20 PM
Compare files kharen11 UNIX for Advanced & Expert Users 25 03-14-2007 03:35 AM
compare two files fredao Shell Programming and Scripting 17 01-31-2007 05:39 AM
Compare 2 files agustincm SUN Solaris 2 10-16-2006 10:32 PM
Compare two files penfold Shell Programming and Scripting 3 04-28-2005 10:04 PM


web tracker

All times are GMT -5. The time now is 12:30 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
UNIX Forum Content Copyright ©1993-2008 SilkRoad Asia All Rights Reserved -Ad Management by RedTyger

Search Engine Optimization by vBSEO 3.1.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93