Find matching timestamps in two files.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Find matching timestamps in two files.
# 1  
Old 07-29-2014
Find matching timestamps in two files.

OK.

if the first file is :

Code:
   3184  2014-07-28 04:15  global.Remote-Access  10.111.8.25 81.245.6.25 tcp 3268
   3035  2014-07-28 04:16 global.Remote-Access  10.111.8.12 81.245.6.25 tcp 3268

If the second file is:


Code:
 1 Jul 28 04:12 2014-07-28  id967254(BGC-TLW-Cert)[BGC-TLW-INFO] Tunneling: User with IP 10.111.8.12 10 connected
      1 Jul 28 04:15 2014-07-28  id920767(BGC-TLW-Cert)[BGC-TLW-INFO] Tunneling: User with IP 10.111.8.25 connected
      1 Jul 28 04:16 2014-07-28  ID926072(BGC-TLW-Cert) [Tunneling:User with IP 10.111.8.12  connected

the 3rd file will be:
if the IP address in the file 1 is equal to file 2 , and if the time (hh:mm) is in the file 1 is equal to file2, then displays:

Code:
   3184  04:15 2014-07-28 global.Remote-Access  id920767(BGC-TLW-Cert)[BGC-TLW-INFO] 10.111.8.25 81.245.6.25 tcp 3268
   3035  04:16 2014-07-28 global.Remote-Access  ID926072(BGC-TLW-Cert) 10.111.8.12 81.245.6.25 tcp 3268

any help will appreciated...
Moderator's Comments:
Mod Comment Please get into the habit of ALWAYS using CODE tags when displaying full line (or multi-line) sample input, output, or code samples, and ICODE tags when displaying partial line sample input, output, or code smiles.

Last edited by fxsme; 07-29-2014 at 06:40 AM.. Reason: Add CODE tags.
# 2  
Old 07-29-2014
How did you adapt the proposals given in How to delete a character using sed and or awk? to this NEW problem?

Last edited by RudiC; 07-29-2014 at 07:10 AM..
# 3  
Old 07-29-2014
really i don't know ....
# 4  
Old 08-01-2014
Code:
awk 'FNR==NR{a[$2$3$5];next} ($5$4$(NF-1)) in a' file1 file2

???
# 5  
Old 08-01-2014
Code:
awk 'NR == FNR {t=($4 $5 $(NF-1));
  $1=$2=$3=$4=$5=X;
  $0=$0; $1=$1;
  sub(/].*$/, "]");
  a[t] = $0; next}
  ($3 $2 $5) in a {$4 = ($4 " " a[$3 $2 $5])}1' file2 file1

# 6  
Old 08-01-2014
Hi

Does n't work... the output doesn't displays login, dst IP address, proto and port....
# 7  
Old 08-01-2014
It would be helpful if you could provide the above code output
Also, you talking column names and we are not aware of which column you are referring to
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

find Search - Find files not matching a pattern

Hello all, this is my first and probably not my last question around here. I do hope you can help or at least point me in the right direction. My question is as follows, I need to find files and possible folders which are not owner = AAA group = BBB with a said location and all sub folders ... (7 Replies)
Discussion started by: kilobyter
7 Replies

2. Shell Programming and Scripting

how to find files matching a pattern and zip

Hi, I want to find all directories matching given pattern in current directory and zip those files. I am trying to do somethign like this. But it is not working. for FNAME in $(find . -type d | grep './\{2\}-\{2\}$'); do zip -r MatchedFiles.zip $FNAME rm -fr $FNAME done ... (4 Replies)
Discussion started by: james423
4 Replies

3. UNIX for Dummies Questions & Answers

Find php files within any matching directory name?

I am trying to search my linux box for any PHP files located within ANY directory matching a certain name. So far nothing I've tried (nor any idea I've searched for) has worked as expected. I have tried a combination of find and grep...fail. Please help? (4 Replies)
Discussion started by: macwise7
4 Replies

4. Shell Programming and Scripting

To find files by matching a pattern in file name

Hi all, I have to check whether certain files exist using a if statement. I have to check this by matching a pattern of filename: e.g. if ] This statement should be "true" if any files like test.dat11, test.dat22 etc are present in the source dir. However, this statement is checking only... (2 Replies)
Discussion started by: sweety123
2 Replies

5. Shell Programming and Scripting

How to find the matching data b/w 2 files in perl?

Hi friends,, i have find the matching data between 2files. My file1 have a data like rs3001336 rs3984736 rs2840532 File2 have a data like rs3736330 1 2359237 A G 0.28 1.099 0.010 rs2840532 1 2359977 G A 0.363 0.3373 1.123 rs3001336 1 ... (4 Replies)
Discussion started by: sureshraj
4 Replies

6. Programming

How to find the matching data b/w 2 files in perl?

Hi friends,, i have find the matching data between 2files. My file1 have a data like rs3001336 rs3984736 rs2840532 File2 have a data like rs3736330 1 2359237 A G 0.28 1.099 0.010 rs2840532 1 2359977 G A 0.363 0.3373 1.123 rs3001336 1 2365193 G A 0.0812 0.07319 1.12 ... (1 Reply)
Discussion started by: sureshraj
1 Replies

7. Shell Programming and Scripting

How to find the matching numbers between 2 files Using R language??

Hi friends,, I need ur help very urgently.I have 2 files which have more than 5000 numbers,I want to find the matching numbers between 2 files using R language.I dont know how to use for loop in R.I tried to get a result,,but didnt get, file1 is like 1061909 1162391... (1 Reply)
Discussion started by: sureshraj
1 Replies

8. UNIX for Dummies Questions & Answers

find files NOT matching name pattern

Hi, I have following files in my directory: /TESTDONTDEL> ls -alt total 14 drwxr-xr-x 2 oracle dba 1024 May 15 06:30 . -rw-r--r-- 1 oracle dba 40 May 15 06:30 exception.txt -rw-r--r-- 1 oracle dba 19 May 15 06:22 ful_1234_test1.txt -rw-r--r-- 1... (2 Replies)
Discussion started by: sagarparadkar
2 Replies

9. UNIX for Dummies Questions & Answers

Find files matching a pattern

Hi, I am writing a BASH shell script. I would like to count all the files in the CURRENT directory matching a specific pattern. Could someone suggest the best/simplest way to do this. I have thought of these solutions (for simplicity the pattern is all files starting with A): ls -1 *A | wc -l... (5 Replies)
Discussion started by: msb65
5 Replies

10. UNIX for Dummies Questions & Answers

Find matching lines between 2 files

How do I find matching lines between two files? (5 Replies)
Discussion started by: jojojmac5
5 Replies
Login or Register to Ask a Question