FTP Log File

Hello,

I need help to check content of ftp log files. I forgot to say that I am on Solaris 9. I am using KSH.

I have 2 log files.

Here is an example of content :

LOG File from 21 October

-rw-rw-r--  1 cvbntr  xarf  94974 Nov  1  2009 TAG__SC___2006175_0.TAB
-rw-rw-r--  1 cvbntr  xarf  94974 Nov  1  2009 TAG__SC___2006175_0.HDR
-rw-rw-r--  1 cvbntr  xarf   3563 May  8 04:07 TAG__KSM__2012063_0.HDR
-rw-rw-r--  1 cvbntr  xarf   3585 May  8 04:07 TAG__KSO__2012063_0.HDR
-rw-rw-r--  1 cvbntr  xarf  95106 Aug 31 12:56 MAG__KSO__2012171_0.TAB
-rw-rw-r--  1 cvbntr  xarf   3647 Aug 31 12:56 MAG__KSO__2012171_0.HDR
-rw-rw-r--  1 cvbntr  xarf  83424 Oct 21 02:41 TAG__SC___2012230_0.TAB
-rw-rw-r--  1 cvbntr  xarf   3602 Oct 21 02:41 TAG__SC___2012230_0.HDR

LOG File from 22 October

-rw-rw-r--  1 cvbntr  xarf  95974 Nov  1  2009 TAG__SC___2006175_0.TAB
-rw-rw-r--  1 cvbntr  xarf  95974 Nov  1  2009 TAG__SC___2006175_0.HDR
-rw-rw-r--  1 cvbntr  xarf   3563 May  8 04:07 TAG__KSM__2012063_0.HDR
-rw-rw-r--  1 cvbntr  xarf   3585 May  8 04:07 TAG__KSO__2012063_0.HDR
-rw-rw-r--  1 cvbntr  xarf  95106 Aug 31 12:56 MAG__KSO__2012171_0.TAB
-rw-rw-r--  1 cvbntr  xarf   3647 Aug 31 12:56 MAG__KSO__2012171_0.HDR
-rw-rw-r--  1 cvbntr  xarf  83424 Oct 22 02:41 TAG__SC___2012230_0.TAB
-rw-rw-r--  1 cvbntr  xarf   3602 Oct 22 02:41 TAG__SC___2012230_0.HDR

What I need :

1 : Find the new files : Files that does not exist on the old ftp log file : print date size & filename
2 : Find the files with a grather size on the new log file ( compare to the old ftp log file ) : : print date size & filename

NOTE : I can't trust dates of files as some old files may be reprocess and get a new date, and some others not. ( I assume you imagine the mess )

Here is output needed as an example :

RESULT PART 1 : 0
RESULT PART 2 : 
Nov  1  2009 95974 TAG__SC___2006175_0.TAB
Nov  1  2009 95974 TAG__SC___2006175_0.HDR

Thanks a lot for your help.

Pls use this as a starter to be improved; you may want to sort it according to your rules (for testing I modified your second file for a new name):

awk 'NR==FNR{Ar[$9]=$5;next}
     !($9 in Ar) {print "Rule 1:", $5,$6,$7,48,$9}
     ($9 in Ar) &&  $5>Ar[$9] {print "Rule 2:", $5,$6,$7,48,$9}
    ' file1 file2
Rule 2: 95974 Nov  1 48 TAG__SC___2006175_0.TAB
Rule 2: 95974 Nov  1 48 TAG__SC___2006175_0.HDR
Rule 1: 83424 Oct 22 48 TAG__SC___2012230_0.TAv

For the size comparison you may need to ensure the two fields to be numerically compared, e.g. by adding a 0 to each field.

Dear Rudic,

thanks a lot for your help, but what do you mean by :

For the size comparison you may need to ensure the two fields to be numerically compared, e.g. by adding a 0 to each field.     

Do you mind to show me how ? I forgot to say that I am on solaris 9 and I using KSH.

Do you know if it's possible to add a check to see if a file in "ftp log 2" ( the new one ) a file will have a smaller size than the size in "ftp log 1" the older one ? That could be, "rule 3".

example :

the file will have 83924 in ftp log 2, and 95974 in ftp log 1 ..

Thanks again for your help

On my linux/mawk system it will compare sizes OK. If it doesn't on yours, force it to be numerical like $5+0 > Ar[$9]+0 . For a third rule, you copy the entire comparing line and invert the comparison. Don't forget to change rule 2 to rule 3 in the print cmd.

1 Like