#! /bin/bash

PROG_NAME=${0##*/}
PROG_DESC="reads the output of {find-all-files-size-date} and makes it more standardized"
PROG_HELP=( "${PROG_NAME} < {INFILE}.sdf > {OUTFILE}.sdf" )
PROG_INFO=(
  "\nNAME"
  "\n  ${PROG_NAME} - ${PROG_DESC}."
  "\n"
  "\nSYNOPSIS"
  "\n  ${PROG_HELP[@]}"
  "\n"
  "\nDESCRIPTION"
  "\n  Reads the output of {find-all-files-size-date}.  Tries to make it more uniform so that oldand new outputs can be compared.  That required deleting the hour, because of local/UTC variation, and printing the size in a standard width;"
  "\n" \
  "\nSEE ALSO"
  "\n  find-all-files-size-date"
  "\nAUTHOR"
  "\n  Created 2020-09-04 by Jorge Stolfi, Unicamp"
)

# Check for spurious arguments:
if [[ $# -ne 0 ]]; then
  echo 'this script takes no arguments "'"$1"'" ...' 1>&2
  echo -e "usage:\n  ${PROG_HELP[@]}" 1>&2 ; exit 1 
fi

# Prefix for temporary file names
tmp="/tmp/$$"

gawk \
  ' // {
      sz = $1; dt = $2; fn = $3;
      dtnew = (substr(dt,1,11) "xx" substr(dt,14));
      printf "%18d %s %s\n", sz, dtnew, fn;
    }
  '
