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
$ \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's "old, broken awk". Don't use it. Use GNU awk (gawk), New awk (nawk), or
/usr/xpg4/bin/awk on Solaris.
> the last time it worked was
>
> ls -l | awk ' $6=="Dec"&& $7=="29" {print $0}'
You could do it that way with:
ls -l | awk '$6=="Dec" && $7=="29" && $8 ~ /^08/'
but that wouldn't work for older files whose ls -l output is in "month day year"
format rather than "month day time" format so you'd get a more robust solution
using "find -maxdepth 1" with "-mtime" or "-newer" options. man find for details.
Ed.
absolutely right. sometimes you keep spinnin' on the same error, just
because you figure out first
Thanks Ed. i was struggling with find first but their search was
time relative..
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.
> 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.
>>> $ \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@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/
$
You could use the -newer option of find and some limit files:
touch -t 200912291059.59 oldest
touch -t 200912291200.00 newest
find <dir> -newer oldest ! -newer newest -ls
cygwin recently switched to using LC_ALL=C.UTF-8 as the default system
locale. It's very new and the growing pains are still non-trivial.
It's worse than simply switching a linux distribution to utf-8 because
you have the underlying windows and it's locale intermixing with the
cygwin layer interpolating things on top.
It's been productive as some corner cases have been popping up and
patches pushed back upstream; in a strange sense MS has been
contributing to the improvement of Free software.
Since many apps are inconsistent about checking locale info it's not
surprising that comparing different environments produce different
results. It's actually surprising that anything works at all.
It's somehow comforting to be fighting backspace and delete problems
yet again. It's less frustrating that struggling with the language/api
de jour.
On a portability note, I find myself writing things like
LC_ALL=C sed ...
I'm certainly much more aware of assumptions that I've been blissfully
ignorant of in the past.