From: Ed Morton on
On 12/31/2009 8:04 AM, mop2 wrote:
> On Thu, 31 Dec 2009 11:49:47 -0200, Atropo <lxvasquez(a)gmail.com> wrote:
>
>> Hi all,
>>
>> I searched similar post about, but some of them i didn't understand
>> and the others were about file name manipulation. what i want is just
>> list the files of an specific hour (any minute) from specific date.
>> i stuck with the hour part.
>>
>> ls -l | awk ' if (($6=="Dec") && ($7=="29") && ( $8 ~ /08/ )) {print
>> $0}'
>>
>> /usr/bin/awk on solaris 9
>>
>> the last time it worked was
>>
>> ls -l | awk ' $6=="Dec" && $7=="29" {print $0}'
>>
>
> Well, without awk, but is easy to undertand:
>
> $ \ls -l|grep '2009-12-29 11'
> drwxr-xr-x 5 web ppp 4096 2009-12-29 11:55 gtkdialog-0.7.20
> -rw-r--r-- 1 web ppp 280408 2009-12-29 11:54 gtkdialog-0.7.20.tar.gz
> drwx------ 5 web ppp 4096 2009-12-29 11:40 yaf-splash-1.02
> -rw-r--r-- 1 web ppp 81391 2009-12-29 11:30 yaf-splash-1.02.tar.gz

What shell are you using? I tried bash on cygwin and ksh on Solaris and they
both produce the "monthname dayname time" timestamp.

> $ \ls -l|grep '2009-12-29 11'|tr -s ' '|cut -d' ' -f8-
> gtkdialog-0.7.20
> gtkdialog-0.7.20.tar.gz
> yaf-splash-1.02
> yaf-splash-1.02.tar.gz

That "tr" would corrupt file names that contain consecutive spaces so if you're
relying on file names not containing spaces you can reduce that line to:

$ \ls -l|awk '2009-12-29 11{print $8}'

Regards,

Ed.

From: mop2 on
On Thu, 31 Dec 2009 12:20:21 -0200, Ed Morton <mortonspam(a)gmail.com> wrote:

> On 12/31/2009 8:04 AM, mop2 wrote:

>> $ \ls -l|grep '2009-12-29 11'
>> drwxr-xr-x 5 web ppp 4096 2009-12-29 11:55 gtkdialog-0.7.20
>> -rw-r--r-- 1 web ppp 280408 2009-12-29 11:54 gtkdialog-0.7.20.tar.gz
>> drwx------ 5 web ppp 4096 2009-12-29 11:40 yaf-splash-1.02
>> -rw-r--r-- 1 web ppp 81391 2009-12-29 11:30 yaf-splash-1.02.tar.gz
>
> What shell are you using? I tried bash on cygwin and ksh on Solaris and they
> both produce the "monthname dayname time" timestamp.
>

Hi Ed,

$ $0 --version|head -n1;ls --version|head -n1
GNU bash, version 4.0.35(1)-release (i686-pc-linux-gnu)
ls (GNU coreutils) 8.2

$ for s in `\ls /bin/*sh`;do $s -c "printf \"\$0:\t\";ls -l xtctl";done 2>/dev/null
/bin/ash: -rwxr-xr-x 1 web ppp 3515 2009-10-16 12:08 xtctl
/bin/bash: -rwxr-xr-x 1 web ppp 3515 2009-10-16 12:08 xtctl
/bin/ksh: -rwxr-xr-x 1 web ppp 3515 2009-10-16 12:08 xtctl
/bin/rksh: -rwxr-xr-x 1 web ppp 3515 2009-10-16 12:08 xtctl
/bin/sh: -rwxr-xr-x 1 web ppp 3515 2009-10-16 12:08 xtctl
/bin/zsh: -rwxr-xr-x 1 web ppp 3515 2009-10-16 12:08 xtctl

I don't know why this time format is here, but I like it.


>> $ \ls -l|grep '2009-12-29 11'|tr -s ' '|cut -d' ' -f8-
>> gtkdialog-0.7.20
>> gtkdialog-0.7.20.tar.gz
>> yaf-splash-1.02
>> yaf-splash-1.02.tar.gz
>
> That "tr" would corrupt file names that contain consecutive spaces so if you're
> relying on file names not containing spaces you can reduce that line to:
>
> $ \ls -l|awk '2009-12-29 11{print $8}'
>

Yeah, spaces are ever an inconvenient element to consider (and remember) when
they aren't just separators.
This is a complicator to awk too.
And, if a file contains a space in its name, more than one consecutive are also possible.
From: pk on
mop2 wrote:

>>> $ \ls -l|grep '2009-12-29 11'
>>> drwxr-xr-x 5 web ppp 4096 2009-12-29 11:55 gtkdialog-0.7.20
>>> -rw-r--r-- 1 web ppp 280408 2009-12-29 11:54 gtkdialog-0.7.20.tar.gz
>>> drwx------ 5 web ppp 4096 2009-12-29 11:40 yaf-splash-1.02
>>> -rw-r--r-- 1 web ppp 81391 2009-12-29 11:30 yaf-splash-1.02.tar.gz
>>
>> What shell are you using? I tried bash on cygwin and ksh on Solaris and
>> they both produce the "monthname dayname time" timestamp.
>>
>
> Hi Ed,
>
> $ $0 --version|head -n1;ls --version|head -n1
> GNU bash, version 4.0.35(1)-release (i686-pc-linux-gnu)
> ls (GNU coreutils) 8.2
>
> $ for s in `\ls /bin/*sh`;do $s -c "printf \"\$0:\t\";ls -l xtctl";done
> 2>/dev/null
> /bin/ash: -rwxr-xr-x 1 web ppp 3515 2009-10-16 12:08 xtctl
> /bin/bash: -rwxr-xr-x 1 web ppp 3515 2009-10-16 12:08 xtctl
> /bin/ksh: -rwxr-xr-x 1 web ppp 3515 2009-10-16 12:08 xtctl
> /bin/rksh: -rwxr-xr-x 1 web ppp 3515 2009-10-16 12:08 xtctl
> /bin/sh: -rwxr-xr-x 1 web ppp 3515 2009-10-16 12:08 xtctl
> /bin/zsh: -rwxr-xr-x 1 web ppp 3515 2009-10-16 12:08 xtctl
>
> I don't know why this time format is here, but I like it.

It seems somehow related to localization, eg see

# LC_ALL=C ls -l foo
-rw-r--r-- 1 root root 356 Nov 17 23:14 foo
# LC_ALL=en_US.utf8 ls -l foo
-rw-r--r-- 1 root root 356 2009-11-17 23:14 foo

From: Bill Marcum on
On 2009-12-31, Ed Morton <mortonspam(a)gmail.com> wrote:
> On 12/31/2009 8:04 AM, mop2 wrote:
>> $ \ls -l|grep '2009-12-29 11'
>> drwxr-xr-x 5 web ppp 4096 2009-12-29 11:55 gtkdialog-0.7.20
>> -rw-r--r-- 1 web ppp 280408 2009-12-29 11:54 gtkdialog-0.7.20.tar.gz
>> drwx------ 5 web ppp 4096 2009-12-29 11:40 yaf-splash-1.02
>> -rw-r--r-- 1 web ppp 81391 2009-12-29 11:30 yaf-splash-1.02.tar.gz
>
> What shell are you using? I tried bash on cygwin and ksh on Solaris and they
> both produce the "monthname dayname time" timestamp.
>
It's the ls program, not the shell, that determines the date format, and
that can vary depending on the locale. GNU ls has the "--full-time" option
which always gives the date, time and year. Other versions of ls often
omit the year for files less than 6 months old, and omit the time for older
files or files with a future time stamp.

From: mop2 on
On Thu, 31 Dec 2009 13:07:59 -0200, pk <pk(a)pk.invalid> wrote:

> mop2 wrote:
>
>>>> $ \ls -l|grep '2009-12-29 11'
>>>> drwxr-xr-x 5 web ppp 4096 2009-12-29 11:55 gtkdialog-0.7.20
>>>> -rw-r--r-- 1 web ppp 280408 2009-12-29 11:54 gtkdialog-0.7.20.tar.gz
>>>> drwx------ 5 web ppp 4096 2009-12-29 11:40 yaf-splash-1.02
>>>> -rw-r--r-- 1 web ppp 81391 2009-12-29 11:30 yaf-splash-1.02.tar.gz
>>>
>>> What shell are you using? I tried bash on cygwin and ksh on Solaris and
>>> they both produce the "monthname dayname time" timestamp.
>>>
>>
>> Hi Ed,
>>
>> $ $0 --version|head -n1;ls --version|head -n1
>> GNU bash, version 4.0.35(1)-release (i686-pc-linux-gnu)
>> ls (GNU coreutils) 8.2
>>
>> $ for s in `\ls /bin/*sh`;do $s -c "printf \"\$0:\t\";ls -l xtctl";done
>> 2>/dev/null
>> /bin/ash: -rwxr-xr-x 1 web ppp 3515 2009-10-16 12:08 xtctl
>> /bin/bash: -rwxr-xr-x 1 web ppp 3515 2009-10-16 12:08 xtctl
>> /bin/ksh: -rwxr-xr-x 1 web ppp 3515 2009-10-16 12:08 xtctl
>> /bin/rksh: -rwxr-xr-x 1 web ppp 3515 2009-10-16 12:08 xtctl
>> /bin/sh: -rwxr-xr-x 1 web ppp 3515 2009-10-16 12:08 xtctl
>> /bin/zsh: -rwxr-xr-x 1 web ppp 3515 2009-10-16 12:08 xtctl
>>
>> I don't know why this time format is here, but I like it.
>
> It seems somehow related to localization, eg see
>
> # LC_ALL=C ls -l foo
> -rw-r--r-- 1 root root 356 Nov 17 23:14 foo
> # LC_ALL=en_US.utf8 ls -l foo
> -rw-r--r-- 1 root root 356 2009-11-17 23:14 foo
>
>

pk,
you are right, tanks:

$ set|grep '^L[AC]'
LANG=en_US
LC_COLLATE=C
LC_CTYPE=fr_FR(a)euro
$ ls -ld /tmp
drwxrwxrwt 137 root root 40960 2009-12-31 11:46 /tmp/
$ unset LC_CTYPE
$ ls -ld /tmp
drwxrwxrwt 137 root root 40960 2009-12-31 11:46 /tmp/
$ unset LANG
$ ls -ld /tmp
drwxrwxrwt 137 root root 40960 Dec 31 11:46 /tmp/
$