List file modification date with Year

I am doing ls -lt and this command sometime lists the year of modification but sometime just lists, Month, Day and the time. I need the Month, Day and the Year of the last modification.

ls -lt file.txt | nawk '{print $6-$7-$8}'

Would like the result to be: Oct-22-2008

Thanks for your help.
infa007Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

woolmilkporcCommented:

You don't see the year when less than 6 months (ca.) passed.
0
woolmilkporcCommented:
Hi again,I just saw that gnu ls behaves differently. Try it!
It's in GNU coreutils>
http://ftp.gnu.org/gnu/coreutils/
Norbert
 
0
woolmilkporcCommented:
GNU docs concerning ls timestamps>

The following option changes how file timestamps are printed. --time-style=style List timestamps in style style. The style should be one of the following: +format List timestamps using format, where format is interpreted like the format argument of date (see date invocation). For example, --time-style="+%Y-%m-%d %H:%M:%S" causes ls to list timestamps like 2002-03-30 23:45:56. As with date, format's interpretation is affected by the LC_TIME locale category.
If format contains two format strings separated by a newline, the former is used for non-recent files and the latter for recent files; if you want output columns to line up, you may need to insert spaces in one of the two formats.
full-iso List timestamps in full using ISO 8601 date, time, and time zone format with nanosecond precision, e.g., 2002-03-30 23:45:56.477817180 -0700. This style is equivalent to +%Y-%m-%d %H:%M:%S.%N %z.
This is useful because the time output includes all the information that is available from the operating system. For example, this can help explain make's behavior, since GNU make uses the full timestamp to determine whether a file is out of date.
long-iso List ISO 8601 date and time in minutes, e.g., 2002-03-30 23:45. These timestamps are shorter than full-iso timestamps, and are usually good enough for everyday work. This style is equivalent to +%Y-%m-%d %H:%M.
iso List ISO 8601 dates for non-recent timestamps (e.g., 2002-03-30 ), and ISO 8601 month, day, hour, and minute for recent timestamps (e.g., 03-30 23:45). These timestamps are uglier than long-iso timestamps, but they carry nearly the same information in a smaller space and their brevity helps ls output fit within traditional 80-column output lines. The following two ls invocations are equivalent: newline=' ' ls -l --time-style="+%Y-%m-%d $newline%m-%d %H:%M" ls -l --time-style="iso"  
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

TintinCommented:
What Unix/Linux flavour are you running?
0
ahoffmannCommented:
depending on your OS try one of:

ls -E
ls --full-time
ls --time-style=full-iso
0
infa007Author Commented:
Neither of them works :(
0
woolmilkporcCommented:
Hi,
do you have GNU coreutils?
If no, get it here -
http://ftp.gnu.org/gnu/coreutils/ 
 
If yes, try
ls -l --time-style="+%b-%d-%Y"
 
wmp
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
TintinCommented:
Define what you mean by not working.

Do you get any errors?

What Unix/Linux flavour are you trying to run this on?
0
infa007Author Commented:
Well i did a uname -a, got AIX
0
woolmilkporcCommented:
Hi,
 so you probably will have to install GNU coreutils from the Linux Toolbox for AIX.

If you don't have the CD, get the rpm here:
http://www-03.ibm.com/systems/p/os/aix/linux/toolbox/download.html

If you need some hints, please post!

wmp
 
0
ozoCommented:
perldoc perlref
perldoc perllol
0
ozoCommented:
Sorry, posted to wrong question
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Shell Scripting

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.