coolcommands.com - the search engine for unix sysadmins :: unix commands and scripts
Sunday May 27, 2012


 Home
 Search
 Advanced Search
 Category Search
 Affiliates
 Acknowledgements
 Cool Links

Username

Password

Remember me
Forgot your password?
Create an account

Who's Online
We have 39 guests online

Newest Member

advaxavardimb

Hit Counter
9134404 Visitors

cool Statistics
coolcommands:1330
Categories:83
Total queries:595502
Members:16439





Category Search coolcommands.com
Select Category:


coolcommand

stat_f - to list the modification timestamp of a file up to the second
Description

Here is a "quick & dirty" C program to list the modification timestamp of a file up to the second:


#include <sys/stat.h>
#include <sys/errno.h>
#include <stdio.h>
#include <strings.h>
#include <time.h>
#include <locale.h>
#include <langinfo.h>

int main (int argc, char *argv[]) {

int ret;
struct stat inode;
struct tm *tm;
char date_str[256];

ret = stat( argv[1], &inode);
if (ret == -1) {
printf("errno = %s\n", strerror(errno));
exit(1);
}
tm = localtime(&inode.st_mtime);
strftime(date_str, sizeof(date_str), nl_langinfo(D_T_FMT), tm);
printf("%s\t%s\n", date_str, argv[1]);
}
Example

gcc -o stat_f stat_f.c; stat_f /etc/motd

Return to search results

Random coolcommands

coolcommand: bootlist - how to modify the boot list in IBM AIX
Example: bootlist -m normal hdisk0 hdisk1
[show me the details]
coolcommand: procwdx - how to print the current working directory of a process in AIX 5L
Example: procwdx 258226
[show me the details]
coolcommand: oslevel - show the filesets below a specific maintenance level in IBM AIX
Example: oslevel -rl 5200-03
[show me the details]
coolcommand: how to shutdown a Sybase server
Example: shutdown
[show me the details]

coolcommands.com - the search engine for UNIX sysadmins :: unix commands and scripts



FREE
myPMS

Password
Management
System

by

LVOware.com




Top 5 Submitters

lvo1152
audet37
kah00na32
Mariom24
lebjf00014

Top 5 Searches

Category Solaris49379
Category AIX46267
Category General UNIX43934
solaris22927
aix22116

Terms of Use
Privacy
Contact


 
coolcommands.com © 2012. All Right Reserved.
Programming by PRATTICO Consulting . Hosting by Apricusum