[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: date does not support pipes
From: |
Kaz Kylheku |
Subject: |
Re: date does not support pipes |
Date: |
Mon, 15 Jan 2024 18:57:23 -0800 |
User-agent: |
Roundcube Webmail/1.4.15 |
On 2024-01-12 20:14, Philip Rogers wrote:
> Hi,
>
> `date` seems not to support reading from stdin.
>
> So if you want the "last data modification" date of a file, in ISO8601 format
> at the seconds level, you have to:
>
> stat --format "%Y" check.txt | { read ts; date -d@"$ts"; }
You want process substitution:
date -d@$(stat --format "%Y" check.txt)
It's too easy to interpolate the numeric time into the date
command line. Even if we are doing fork + exec in C,
it's just a snprintf job to produce a "-d@12345..."
argument.