The while statements are needed to determine which line number matches the latest date. I tried using regular expressions to do this but could not figure it out. When I execute this script it sometimes returns the correct $i, sometimes executes the wrong $if statement. Thanks!$earliest0 = `more $ARGV[0]| grep -v Epoch > newfile.txt| head -1 newf +ile.txt`; @Array0 = split(' ',$earliest0); $date0 = "@Array0[0] @Array0[1]"; $earliest1 = `more $ARGV[1]| grep -v Epoch > newfile1.txt| head -1 new +file1.txt`; @Array1 = split(' ',$earliest1); $date1 = "@Array1[0] @Array1[1]"; if($date0 eq $date1){$early = $ARGV[0]; $late = $ARGV[1];} if($date0 lt $date1){$early = $ARGV[0]; $late = $ARGV[1]; $File = "newfile.txt"; open(File); $i = 0; while(<File>){ @check = split(' ',$_); $date = "@check[0] @check[1]"; if($date eq $date1){last;} $i++; } } if($date1 lt $date0){$early = $ARGV[1]; $late = $ARGV[0]; $File = "newfile1.txt"; open(File); $i = 0; while(<File>){ @check = split(' ',$_); $date = "@check[0] @check[1]"; if($date eq $date0){last;} $i = $i++; } }
In reply to Re^2: Time matching YYYY-MM-DD HH:MM:SS.SSS
by PRyanRay
in thread Time matching YYYY-MM-DD HH:MM:SS.SSS
by PRyanRay
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |