The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Printing Year in ls -ltr command ragugct Shell Programming and Scripting 9 07-11-2008 07:11 AM
Network Command for Listing Wireless networks Octal UNIX for Dummies Questions & Answers 1 06-07-2007 06:44 PM
ls command for listing the number of files jimmyc UNIX for Dummies Questions & Answers 4 03-23-2007 09:34 PM
Easy one : command listing total memory beginer HP-UX 4 05-31-2006 05:22 AM
TAR command , listing backed up files FredSmith SUN Solaris 3 10-03-2005 07:08 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 08-15-2007
Registered User
 

Join Date: Oct 2004
Posts: 235
listing year in ls command

Hi all ..

As per rule i searched the forum i am not able found out ...

I want to display the year in when listing the files .. when i use ls -lt it is not displaying files with recent 6 month old ..

I know that perderabo has written a script for that if you give that link it will be usefull..

i want to display the file listing with year ...

Else if the is a way please let me know .. Tried ls -lT there no option i my HP_UNIX for ls with T ...


Thanks in advance
Arun ..
Reply With Quote
Forum Sponsor
  #2  
Old 08-16-2007
Registered User
 

Join Date: Oct 2004
Posts: 235
Any one please let me know how to display year when doing LS.. please let me know how can that done by shell script .. or else is there is any option in ls .I did man ls as well but no result ...
Reply With Quote
  #3  
Old 08-16-2007
blowtorch's Avatar
Supporter
 
Join Date: Dec 2004
Location: Singapore
Posts: 2,326
Please do not bump your posts.

And the behaviour of ls is such that the year is displayed only for files older than 6 months. If you want the year for files less than 6 months old, you will have to write a program either in C/perl/python that does the task.

The basic system call that you will use is stat(2). You can check the man page for more details. In the structure that stat(2) returns, you will find st_mtime. This is the time in seconds since 00:00:00 UTC, Jan. 1, 1970 that the file was modified. You can pass that onto ctime(3) that will convert the time into a human readable format.
Reply With Quote
  #4  
Old 08-16-2007
Registered User
 

Join Date: Oct 2004
Posts: 235
Thanks Blowtorch ..

I remeber that some where here is form i come across the script that will display the file with year .That was written by perderabo if so any one knows that please send me the link .... i tried to found out but i could not ...

Blowtourch i will try that with c code mean whilw ..

Thanks in advance..

Arun.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 01:49 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0