Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • what is that you actually want to do? Commented Jul 29, 2022 at 21:45
  • I want to use the hours being passed in the second argument to the date command being executed in the awk script (for now it is hardcoded, but would like to use the ttl value. I suspect I'm having quoting/escaping issues here): echo "2022-07-28T18:42:52Z -72" | /usr/bin/awk '{ttl=$2;print ttl}; $1 <= "'$(date -d"now -72 hours" -Ins --utc)'" { print "expired" }' Commented Aug 1, 2022 at 14:54
  • soo, you don't really want to print that second field at all? But instead you want to use it as one of the arguments to the date command? Or, to get even more to the point, you have an line that consists of a timestamp, and some number of hours, and you want to find out if that timestamp is that much in the past? E.g. 2022-07-28T18:42:52Z -72 should give "expired", since it's more than 72 h from that date, but 2022-07-27T11:22:33Z -168 should not, since it's less than 168 h from that date? I'd probably do that in the shell (not awk), with a couple of invocations of date... Commented Aug 1, 2022 at 19:52
  • Yes thanks ilkkachu, that sounds like an easier plan than using awk Commented Aug 3, 2022 at 15:45