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 36 guests online

Newest Member

golfballsmx

Hit Counter
9091447 Visitors

cool Statistics
coolcommands:1330
Categories:83
Total queries:594826
Members:16319





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: how to get the date and time from a remote unix server
Example: telnet hostname 13
[show me the details]
coolcommand: how to recover a failed MPIO paths from an IBM VIO server on an AIX LPAR
Example: chpath -l hdisk0 -p vscsi1 -s disable; chpath -l hdisk0 -p vscsi1 -s enable
[show me the details]
coolcommand: how to restore a mysql database dump
Example: mysql -u root -p < dbname.sql
[show me the details]
coolcommand: how to query the volume group descriptor area on a drive in IBM AIX
Example: lqueryvg -Atp hdisk0
[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 UNIX43849
solaris22926
aix22108

Terms of Use
Privacy
Contact


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