1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
#!/bin/sh
# Stops the execution if a command has an error
set -e
# Defines expected results
EXPECTED=$(cat <<'EOF'
Unix Seconds: 2021-09-19 07:24:36.000000 UTC
Unix Milliseconds: 2021-09-19 07:24:59.334000 UTC
EOF
)
# Run time-decode to decode unix epoch in secs
SECONDS_OUTPUT=$(time-decode --unixsec 1632036276)
# Run time-decode to decode unix epoch in milliseconds
MILLISECONDS_OUTPUT=$(time-decode --unixmilli 1632036299334)
# Combine the outputs
ACTUAL="${SECONDS_OUTPUT}
${MILLISECONDS_OUTPUT}"
if [ "$ACTUAL" = "$EXPECTED" ]; then
exit 0
fi
exit 1
|