Tux

...making Linux just a little more fun!

Talkback:issue75/lg_tips.html#tips/8

[ In reference to "/lg_tips.html" in LG#issue75 ]

Jim Cox [jim.cox at idt.net]


Mon, 31 Aug 2009 09:37:04 -0400

Another option, though I'm not sure if it fits the OP's constraint of "plain shell methods", is stat with a custom format:

prompt$ stat -c %y /tmp/teetime.log 2009-08-31 09:30:11.000000000 -0400

I stumbled across this while looking for filesizes in scripts, seemed a bit cleaner v. cut against ls output:

prompt$ stat -c %s /tmp/teetime.log 7560497


Top    Back


Jim Cox [jim.cox at idt.net]


Mon, 31 Aug 2009 09:37:04 -0400

Another option, though I'm not sure if it fits the OP's constraint of "plain shell methods", is stat with a custom format:

prompt$ stat -c %y /tmp/teetime.log 2009-08-31 09:30:11.000000000 -0400

I stumbled across this while looking for filesizes in scripts, seemed a bit cleaner v. cut against ls output:

prompt$ stat -c %s /tmp/teetime.log 7560497


Top    Back


Thomas Adam [thomas.adam22 at gmail.com]


Mon, 31 Aug 2009 14:45:46 +0100

2009/8/31 Jim Cox <jim.cox@idt.net>:

> Another option, though I'm not sure if it fits the OP's constraint of
> "plain shell methods", is stat with a custom format:
>
> prompt$ stat -c %y /tmp/teetime.log
> 2009-08-31 09:30:11.000000000 -0400
>
> I stumbled across this while looking for filesizes in scripts, seemed a
> bit cleaner v. cut against ls output:
>
> prompt$ stat -c %s /tmp/teetime.log
> 7560497

Uh huh, or see:

ls --time-style=+%s -l

Or my preferred method:

find . -printf '%f:%A\n'

(Find uses stat(2) under the hood anyway.)

-- Thomas Adam


Top    Back


Thomas Adam [thomas.adam22 at gmail.com]


Mon, 31 Aug 2009 14:47:56 +0100

2009/8/31 Thomas Adam <thomas.adam22@gmail.com>:

> 2009/8/31 Jim Cox <jim.cox@idt.net>:
>> Another option, though I'm not sure if it fits the OP's constraint of
>> "plain shell methods", is stat with a custom format:
>>
>> prompt$ stat -c %y /tmp/teetime.log
>> 2009-08-31 09:30:11.000000000 -0400
>>
>> I stumbled across this while looking for filesizes in scripts, seemed a
>> bit cleaner v. cut against ls output:
>>
>> prompt$ stat -c %s /tmp/teetime.log
>> 7560497
>
> Uh huh, or see:
>
> ```
> ls --time-style=+%s -l
> '''
>
> Or my preferred method:
>
> ```
> find . -printf '%f:%A\n'
> '''

My '@' disappeared:

``` find . -printf '%f:%A@\n' '''

-- Thomas Adam


Top    Back