Sponsored Content
Full Discussion: listing year in ls command
Top Forums UNIX for Dummies Questions & Answers listing year in ls command Post 302132299 by blowtorch on Thursday 16th of August 2007 08:40:15 AM
Old 08-16-2007
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.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

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... (9 Replies)
Discussion started by: ragugct
9 Replies

2. Shell Programming and Scripting

Last Command not giving year

Hi All, i want the last login details along with year. i tried below command but not giving me the year of last login. last <$Userid> | head -1 i heard that if it is current year then it wont display the year else it will display the year. is it so? if yes then , is there any way of... (1 Reply)
Discussion started by: ani_rvce
1 Replies

3. UNIX for Dummies Questions & Answers

Last Command not giving year

Hi All, i want the last login details along with year. i tried below command but not giving me the year of last login. last <$Userid> | head -1 i heard that if it is current year then it wont display the year else it will display the year. is it so? if yes then , is there any way of... (1 Reply)
Discussion started by: ani_rvce
1 Replies

4. Emergency UNIX and Linux Support

LAST command with Year

Hi Guys, I'm trying to identify the last logins by all the users in the system in AIX. the last command gives me the output, but there is no year displayed for it . Since there is a duplication of months i mean Apr 2010 and Apr 2009 also its giving me inaccurate data.. Is there a way I can filter... (4 Replies)
Discussion started by: kkeng808
4 Replies

5. Linux

uptime command output when the server is running more than one year?

What is the uptime command output when the server is running more than one year? My doubt is whether it show in number of days format or number years and number of days format? For example, Assume the server is running 400 days 3 hrs 3 min 3 secs. The output like 400 days 3:3 min or 1 year 5... (3 Replies)
Discussion started by: maruthu
3 Replies

6. Shell Programming and Scripting

Listing files that belong to a certain year date?

I'm trying to list files, first by size and I'm using something like this ls -l|awk '{print $5,$6,$7,$8,$9|"sort -nr"}'|more Now I'd like to just do the same listing but only for files with the year 2009 in the $8 field or even anything less than 2011. (5 Replies)
Discussion started by: NycUnxer
5 Replies

7. UNIX for Dummies Questions & Answers

Unix man command to find out month of the year?

how can i display month of the year i was born with using man command? thanks (2 Replies)
Discussion started by: janetroop95
2 Replies

8. Shell Programming and Scripting

find command listing

Hello, I have been trying to understand how the 'find' command lists the search results. I have a list of songs in different file formats (mp3, wav, aac etc) in a huge directory hierarchy organized by genre and am trying to get the list of all songs of a particular format. I found ls -R... (9 Replies)
Discussion started by: ajayram
9 Replies

9. UNIX for Dummies Questions & Answers

Command to print previous year in UNIX

hi all, I use date +%Y which gives Current year. Requirement: I want previous year to be printed. Please help me. Note: I tried date +%d/%m/%Y -d "-1 years" which is not working. (10 Replies)
Discussion started by: wasim999
10 Replies

10. UNIX for Beginners Questions & Answers

Insert year in ls -l command

Hi All, Have a file where i stored ls -l command output, -rw-r--r-- 1 360 600 94255 Jan 01 11:16 file1_2020.csv -rw-r--r-- 1 360 600 114573 Dec 29 11:10 file2_2019.csv -rw-r--r-- 1 360 600 41006 Dec 30 11:09 file3_2019.csv -rw-r--r-- 1 360 ... (9 Replies)
Discussion started by: kumarinfa
9 Replies
shevek::absolute_time(3)				     Library Functions Manual					  shevek::absolute_time(3)

NAME
shevek::absolute_time - The absolute_time class stores a date and time. SYNOPSIS
#include <time.hh> Public Member Functions absolute_time () Create a new absolute_time containing the current time. absolute_time (unsigned years, unsigned months, unsigned days, unsigned hours, unsigned minutes, unsigned seconds, unsigned nanoseconds=0) A specific time. absolute_time (timetype seconds, unsigned nanoseconds) Fast constructor. absolute_time operator+ (relative_time that) const Add an interval to this moment. absolute_time operator- (relative_time that) const Subtract an interval from this moment. relative_time operator- (absolute_time that) const Compute the interval between two moments. absolute_time & operator+= (relative_time that) Add an interval to this moment. absolute_time & operator-= (relative_time that) Subtract an interval from this moment. bool operator< (absolute_time that) const Compare two moments. bool operator> (absolute_time that) const Compare two moments. bool operator<= (absolute_time that) const Compare two moments. bool operator>= (absolute_time that) const Compare two moments. bool operator== (absolute_time that) const Compare two moments. bool operator!= (absolute_time that) const Compare two moments. unsigned nanoseconds () const Get the nanoseconds. unsigned local_second () const Get the seconds in local time. unsigned local_minute () const Get the minutes in local time. unsigned local_hour () const Get the hour in local time. unsigned local_days () const Get the day of the year in local time, range 0-365. unsigned local_day () const Get the day of the month in local time, range 1-31. unsigned local_weekday () const Get the day of the week in local time, range 0-6 where 0 means sunday. unsigned local_month () const Get the month in local time, range 1-12. unsigned local_year () const Get the year in local time. unsigned second () const Get the seconds in UTC. unsigned minute () const Get the minutes in UTC. unsigned hour () const Get the hour in UTC. unsigned days () const Get the day of the year in UTC, range 0-365. unsigned day () const Get the day of the month in UTC, range 1-31. unsigned weekday () const Get the day of the week in UTC, range 0-6 where 0 means sunday. unsigned month () const Get the month in UTC, range 1-12. unsigned year () const Get the year in UTC. timetype total () const Total number of seconds since january 1970, as encoded. sigc::connection schedule (sigc::slot0< void > callback, Glib::RefPtr< Glib::MainContext > context=Glib::MainContext::get_default()) Schedule a callback at a certain time. Static Public Member Functions static absolute_time create_from_local (unsigned years, unsigned months, unsigned days, unsigned hours, unsigned minutes, unsigned seconds, unsigned nanoseconds=0) Semi-constructor which creates a new absolute_time given a date in local time. static void set_digits (unsigned num) Set number of digits to use when printing (for fractions of seconds) static unsigned get_digits () Get the number of digits which is used when printing. Friends sigc::connection schedule (sigc::slot0< void > callback, int prio, Glib::RefPtr< Glib::MainContext > context) Schedule a callback for when the main loop has time. std::ostream & operator<< (std::ostream &s, absolute_time t) Write the time to a std::ostream. Detailed Description The absolute_time class stores a date and time. Everything is in UTC, except the output of local_* (); Constructor &; Destructor Documentation shevek::absolute_time::absolute_time () Create a new absolute_time containing the current time. Note that this makes a call to gettimeofday, which is much slower than specifying seconds and nanoseconds. Thus, if you need an absolute_time object to fill with an actual time later, use absolute_time foo (0, 0); instead of this default constructor. shevek::absolute_time::absolute_time (unsignedyears, unsignedmonths, unsigneddays, unsignedhours, unsignedminutes, unsignedseconds, unsignednanoseconds = 0) A specific time. days may be 0-365, with months 0. If months > 0, both days and months have a base of 1. shevek::absolute_time::absolute_time (timetypeseconds, unsignednanoseconds) Fast constructor. This directly fills the internal structures. It is therefore faster than the other constructors, in particular the default constructor, which makes a kernel call. Member Function Documentation static absolute_time shevek::absolute_time::create_from_local (unsignedyears, unsignedmonths, unsigneddays, unsignedhours, unsignedminutes, unsignedseconds, unsignednanoseconds = 0) [static] Semi-constructor which creates a new absolute_time given a date in local time. The input is the same as for the similar constructor. bool shevek::absolute_time::operator!= (absolute_timethat) const Compare two moments. Note that this is rarely a useful operation, because minor errors may be introduced by computations. In other words: only use this on times which have been set, never on times which have been computed. bool shevek::absolute_time::operator== (absolute_timethat) const Compare two moments. Note that this is rarely a useful operation, because minor errors may be introduced by computations. In other words: only use this on times which have been set, never on times which have been computed. Author Generated automatically by Doxygen for libshevek from the source code. libshevek Fri May 11 2012 shevek::absolute_time(3)
All times are GMT -4. The time now is 01:12 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy