0

I created script to check the files in the folder for 4 hours ago it is working fine because I am using HP UX.

fourago=`date  +"%m %d %H %M" | awk '{ fourago=$3 - 4 ; if ((fourago<4)&&(fourago>3)) { fourago=59 } printf("%.2d%.2d%.2d%.2d\n",$1,$2,fourago,$4) }'`

To check 16 hours ago can I use this like below

sixteenhourago=`date  +"%m %d %H %M" | awk '{ sixteenhourago=$3 - 16 ; if ((sixteenhourago<16)&&(sixteenhourago>3)) { fourhourago=59 } printf("%.2d%.2d%.2d%.2d\n",$1,$2,fourhourago,$16) }'`

I created above command based on below logic Not sure it is correct or not Please help on this. $3 (current Hour) -1, or one hour ago. To make it 16 hours ago we need to use -16.

some files might be 3 hours 59 minutes ago those should still be counted.

ghoti
  • 45,319
  • 8
  • 65
  • 104
Maxtech
  • 111
  • 16
  • What do you want to check in those files? Is `find . -type f -mmin +$((4*60))` not suitable? Is `date --date='-4 hours' +"%m %d %H %M"` also not suitable? – KamilCuk Sep 24 '18 at 10:56
  • @KamilCuk, `-mmin` may not exist in HP/UX, but `-mtime` certainly does. Also, your `date` usage is linuxy, and certainly will not work in HP/UX. – ghoti Sep 24 '18 at 10:57
  • Och, it is HP/UX, with a tag. Didn't see that. Sorry. – KamilCuk Sep 24 '18 at 10:59

0 Answers0