help-bash
[Top][All Lists]
Advanced

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

Re: printf %()T


From: Lee
Subject: Re: printf %()T
Date: Fri, 28 Apr 2023 00:04:07 -0400

On 4/27/23, Lee <ler762@gmail.com> wrote:
> On 4/27/23, Mike McClain <mike.junk.46@att.net> wrote:
>>     Regarding a message Subject: alias not working, I'd like to thank
>> Greg Wooledge and alex xmb ratchev for the tips to getting what I want.
>>
>>     In response to said message Greg Wooledge said, "The printf command
>> can generate timestamps without needing to call date(1)."
>>
>>     I found in 'help printf' the same claim and in 'man 3 strftime'
>> the format strings allowed but can't seem to find how to use that info.
>
> what worked for me was 'man bash' and search for printf
>
>>     I've tried many combinations but no joy.
>>
>>     Would someone please post a sample that works?
>
> semi-working:
>
> $ printf  "%(%A)T  %(%c)T" 1
> Wednesday  Thu 27 Apr 2023 11:48:12 PM EDT
>
> There's clearly a problem with the day of the week :(

The problem is that I missed that the argument needs to be _minus_ 1
$ printf  "%(%a %A %b %B - %c - %F %H:%M:%S)T " -1
Fri Friday Apr April - Fri 28 Apr 2023 12:01:32 AM EDT - 2023-04-28 00:01:32



reply via email to

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