bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Undocumented feature: Unnamed fifo '<(:)'


From: Dennis Williamson
Subject: Re: Undocumented feature: Unnamed fifo '<(:)'
Date: Sun, 28 Jun 2020 10:55:59 -0500

On Sun, Jun 28, 2020, 8:50 AM felix <felix@f-hauri.ch> 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")


reply via email to

[Prev in Thread] Current Thread [Next in Thread]