Find matching timestamps in two files.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Find matching timestamps in two files.
# 8  
Old 08-01-2014
Hi,

The file2.txt must have the format:
Code:
1 2014-07-28 04:12 id967254(BGC-TLW-Cert)[BGC-TLW-INFO] Tunneling: User with IP 10.111.8.12 10 connected       
1  2014-07-28 04:15 id920767(BGC-TLW-Cert)[BGC-TLW-INFO] Tunneling: User with IP 10.111.8.25 connected      
 1  2014-07-28  04:16 ID926072(BGC-TLW-Cert) [Tunneling:User with IP 10.111.8.12  connected

When i execute, i have:
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

# 9  
Old 08-01-2014
Not sure if I can trust your samples nor specification, but try
Code:
awk     'NR==FNR                        {match ($0, "IP [^ ]*");T[$5,$4,substr($0, RSTART+3, RLENGTH-3)]=$6;next}
         $2SUBSEP$3SUBSEP$5 in T        {$5=T[$2,$3,$5] " " $5; print}
        ' file2 file1
3184 2014-07-28 04:15 global.Remote-Access id920767(BGC-TLW-Cert)[BGC-TLW-INFO] 10.111.8.25 81.245.6.25 tcp 3268
3035 2014-07-28 04:16 global.Remote-Access ID926072(BGC-TLW-Cert) 10.111.8.12 81.245.6.25 tcp 3268

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