coolcommands.com - the search engine for unix sysadmins :: unix commands and scripts
Monday May 21, 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 48 guests online

Newest Member

lamonico

Hit Counter
9089349 Visitors

cool Statistics
coolcommands:1330
Categories:83
Total queries:594787
Members:16314





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: alog - list all the available logs in IBM AIX
Example: alog -L
[show me the details]
coolcommand: fwtmp - to get a listing of failed logins in IBM AIX
Example: /usr/sbin/acct/fwtmp < /etc/security/failedlogin
[show me the details]
coolcommand: mtlib - how to show useful statistical data from your robot
Example: mtlib -l /dev/lmcp0 -qS
[show me the details]
coolcommand: how to test if a file exists and is a block special file in a shell script
Example: test -b file; [ -b file ]
[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 Solaris49340
Category AIX46189
Category General UNIX43845
solaris22926
aix22108

Terms of Use
Privacy
Contact


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