Quantcast
Channel: User FloppyDisk - Unix & Linux Stack Exchange
Viewing all articles
Browse latest Browse all 12

Validate Unix Timestamp using BASH

$
0
0

My google-fu has failed me so I'm hoping someone here can point me in the right direction. I'm in the middle of doing some data validation efforts and I suspect the system is recording some invalid dates in the unix epoch format (seconds since the epoch). Is there an easy way in bash, given data that looks like 1357853083 (seconds since the unix epoch) to ascertain if it's a valid unix timestamp or not? Ideally I'm looking for timestamps that cannot be converted to a human readable date as well as timestamps that might render to a future date that's greater than the current date.

I've compiled this monstrosity which converts things into a human readable date, but I can't figure out how to make it find invalid dates.

$ grep "delimiter" * | grep -v "delimiter2" | awk -F"," '{print $2}' | awk -F":" '{print $2}' | awk -F"*" '{print $1}' | awk '{printf("%s", strftime("%Y.%m.%d ",$1)); printf("%s", strftime("%H:%M:%S \n",$1))}' | sort -V

Viewing all articles
Browse latest Browse all 12

Latest Images

Trending Articles





Latest Images