How to convert timestamps to dates in Bash ?
This solution omits the need for the external tty and cat. So we can easily get the answer. It uses date, but could just as easily use gawk. one can change the shebang and replace the set of single ones and double square brackets with and sh this will also run.
#!/bin/bash LANG=C if [[ -z "$1" ]] then if [[ -p /dev/stdin ]] # input from a pipe then read -r p else echo "No timestamp given." >&2 exit fi else p=$1 fi date -d "@$p" +%c