Printing Year in ls -ltr command

Hi,

When retrieving parameters of a file using ls command i need to print the year part . When i do ls -ltr the following output is displayed

-rwxrwxrwx 1 d_infd d_infd 1711 Jan 8 2004 wf1.class.

Here the year part is not displayed only Jan 8 is displayed.

Can any one help m,e in getting year part of the file using ls command.

Thanks in advance.

Ragu

Hi it is displaying the year 2004. Pls. check

Hey Bala,

Thanks a lot for ur reply..

By mistake i have included year part in the exapmle.

It looks like below.

-rwxrwxrwx 1 d_infd d_infd 1711 Jan 8 11:25 wf1.class.

It is giving only time part. I agree with you that some of the files it is giving Year part and some of the files it is not giving ..

Can we give some parameters when creating a file so that year part will get displayed when do ls -ltr

OR

Is there any options available in ls command to display the Year value.

Thanks in advance.

Ragu

If the OS is AIX then if the time of last modification of the file is greater than six months ago, the time field is shown in the format month date year where as files modified within six months the time field is shown as month date time format.

Hi ,
The answer is if the file is modified
<6 month = 'month date time'
>6 months = 'month date year'

Find the extract of the man ls

 -l    Lists in long format,  giving  mode,  ACL  indication,
       number of links, owner, group, size in bytes, and time
       of last modification for each file \(see above\). If the
       file  is  a  special file, the size field instead con-
       tains the major and minor device numbers. If the  time
       of  last  modification is greater than six months ago,
       it is shown in the format \`month date  year'   for  the
       POSIX  locale. When the LC_TIME locale category is not
       set to the POSIX locale, a  different  format  of  the
       time  field  may  be  used.  Files modified within six
       months show \`month date time'. If the file is  a  sym-
       bolic  link,  the filename is printed followed by "-&gt;"
       and the path name of the referenced file.

by
bala

Thank you Balamuragan. I needed this info too! I can easily "grep" for the date that I need.
How do I display all the files for July that Do Not have a year? This would give me only July files for 2008.

man ls, and check for -T option.

This is what I used: give me everything that does not contain 2007; from this list give me Jul 10. I ended up with my list being for current day.

ls -l | grep -v '2007' | grep 'Jul 10' | more

If it's a current year file then it will not show you the year field else it will.

Thanks..

See if this helps :
stat -c "%y|%n" * | grep '2007'