#!/bin/sh -e
#
# mdtime - print file last access and modification date

# stat command
stat_cmd=$(command -v gstat || command -v stat)

# file to be verified
file="$1"

if [ -f "${file}" ]; then
  mod_time=$(${stat_cmd} --format="%y" "${file}")
  acc_time=$(${stat_cmd} --format="%x" "${file}")

  # echo "${file} last access is ${acc_time}, modification time is ${mod_time}"
  printf '%s\n' "${file}"
  printf '%s\n' "last access: ${acc_time}"
  printf '%s\n' "modification: ${mod_time}"
else
  printf '%s\n' "Error: No input file provided or file does not exist."
fi
