On Sun, Jun 28, 2020, 8:50 AM felix <[email protected]> wrote:
>
> _out=$(date -d "$_string" +%s)
> many time in same script, I run something like:
>
> _fifo=$(mktemp -u /tmp/fifo-XXXXXXXX)
> mkfifo $_fifo
> exec 9> >(exec stdbuf -o0 date -f - +%s >$_fifo 2>&1)
> exec 8<$_fifo
> rm $_fifo
>
> Then to convert human datetime to UNIX SECONDS:
>
> echo >&9 $_string
> read -t 1 -u 8 _out
>
>
How is running your
echo >&9 $_string
read -t 1 -u 8 _out
many times better than running your
_out=$(date -d "$_string" +%s)
many times?
Why don't you just use a function?
date_to_epoch () {
date -d "$1" +%s
}
_out=$(date_to_epoch "$_string")