From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fa528,71c71b4846b73ae0 X-Google-Attributes: gidfa528,public X-Google-ArrivalTime: 2001-04-09 07:58:04 PST Path: supernews.google.com!sn-xit-03!supernews.com!logbridge.uoregon.edu!newsfeed.stanford.edu!paloalto-snf1.gtei.net!news.gtei.net!news.compaq.com!news.cpqcorp.net!harris Subject: Re: Can ls show seconds? From: Bob Harris Newsgroups: comp.unix.tru64 Posted-And-Mailed: yes Message-ID: <090420011056580360%harris@zk3.dec.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-transfer-encoding: 8bit User-Agent: YA-NewsWatcher/5.0.1 Date: Mon, 09 Apr 2001 10:56:58 -0400 NNTP-Posting-Host: 16.140.32.194 X-Complaints-To: abuse@Compaq.com X-Trace: news.cpqcorp.net 986828218 16.140.32.194 (Mon, 09 Apr 2001 07:56:58 PDT) NNTP-Posting-Date: Mon, 09 Apr 2001 07:56:58 PDT Organization: Compaq Computer Corporation Xref: supernews.google.com comp.unix.tru64:2057 [[ This message was both posted and mailed: see the "To," "Cc," and "Newsgroups" headers for details. ]] In article , The Juggernaut wrote: X I've been trying to find a way to use ls to show the file creation X time in seconds. It mentions reading LC_TIME, but can this be changed X to force ls to show seconds? Are the seconds even stored? I do not know how to make ls display seconds (I suspect that if you mess around long enough with the locale stuff, it might be possible to hack something so that time will display seconds). However, in answer to your question "Are the seconds even stored?", the answer is YES. The ls command uses lstat(2) to obtain file information including time. The full time values are stored in st_mtime (seconds since 1970) and st_umtime (microseconds). You could write a program to extract and display the time values if you need more precision than is available via the ls command. #include #include #include #include #include main( int argc, char **argv ) { struct stat st; while( argv[1] != NULL ) { if ( lstat( argv[1], &st ) != 0 ) { perror( argv[1] ); exit( EXIT_FAILURE ); } printf( "%s: %s", argv[1], ctime( &st.st_mtime ) ); argv++; } }