Hi, Quoting Santiago Vila (2016-08-18 19:31:30) > Try doing that in standard AWK without those fancy time-handling functions > :-) > > For the basic format it would be something like this: > > date=substr(stamp,1,8) > time=substr(stamp,10,6) > > I leave the extended format as an exercise for the reader.
challenge accepted! To parse the current format just with shell tool, you would do: TZ=0 date -d'2016-08-18T17:09:36Z' +%s You are welcome. I would say that this is even simpler than your awk solution as you don't even need to hardcode any offsets and immediately even get the epoch for easy comparison. > It is in this sense that I said "easier to parse". Really? Now lets try to parse the basic format: TZ=0 date -d'20160818T170936Z' +%s date: invalid date ā20160818T170936Zā Figuring out how to parse the basic format with `date` is left as an exercise to the reader. ;) > Also: The extended format makes the filename a little bit longer and a little > bit more difficult to handle, as the ":" has to be escaped. Why does the colon have to be escaped? Please point me to the part of the POSIX shell documentation (or whatever other language you are using) where you have to escape the colon. Try: echo : Works fine here without any escaping. > In either case: Nobody asked for a way to specify the filename format in a > flexible way? Correct, nobody did. > For example: If I wanted an integer suffix meaning the number of seconds > since the epoch, how I would do that? See my `date` based solution to parse the filename above. Thanks! cheers, josch
signature.asc
Description: signature