Date Time of FLAG

Hi,

I am first sorry to ask for that, but I am in trouble so I hope you will be agreed to help me on this.

I am solaris (ksh).

I have a lots of file but I only need to get the date and time of the flag files.

Here is the "ls -lrt" view :

ls -lrt | grep Flag_Saturne_R*

Return

-rw-r--r-- 1 user15 data 0 Aug  2 08:45 FLAG_SATURNE_R20020731_OK

I need to get the date and time of the file on this format :

jj/mm/aaaa hh:mm

Thanks for your help.

PS : I will add this on a shell script.

Why not:

ls -lrt Flag_Saturne_R*  

Why grep ? And if you like to grep from ls output, then:

ls -lrt | grep "Flag_Saturne_R*"

Why ? Try next in same directory:

echo Flag_Saturne_R*
echo "Flag_Saturne_R*"

Solution something like:

ls -lrt Flag_Saturne_R* | while read line
do
        flds=( $line )
        y=$( date '+%Y' )
        m=${flds[5]}
        d=${flds[6]}
        hhmm=${flds[7]}
        name=${flds[8]}
        case "$m" in
                Jan) m=01 ;;
                Feb) m=02 ;;
                # add rest months here
                Aug) m=08 ;;
                # ...
                Dec) m=12 ;;
        esac
        case "$hhmm" in
                *:*) ;;# it's time
                [12][0-9][0-9][0-9]) # year, not time
                        y="$hhmm"
                        hhmm=00:00
                        ;;
        esac
        echo "$name $m/$d/$y $hhmm"
done

It's probably worth noting that files newer than six months don't show the year, only the Month, Day and Time. Files older than six months don't show the Time, but only shows the Month, Day and Year.

Dear Friends,

Sorry to be so late. I found a way, with PERL ,to solved my problem.

Here is the code. I hope this will help you on such matter. The print date/time will be on this format : jj/mm/aaaa hh:mm:ss

 xargs perl -e 'foreach(@ARGV){my ($sec1, $min1, $hour1, $mday1, $mon1, $year1, $wday1, $yday1, $isdst1) =localtime ((( stat ( $_ )) [9]) ); printf("%02d/%02d/%d %02d:%02d:%02d\n",$mday1,$mon1+1,$year1+1900,$hour1,$min1,$sec1);}'

Thanks for your help.