coolcommands.com - the search engine for unix sysadmins :: unix commands and scripts
Saturday February 11, 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 23 guests online

Newest Member

pletcherwml

Hit Counter
8357997 Visitors

cool Statistics
coolcommands:1328
Categories:83
Total queries:585032
Members:13150





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 increase the tcp receive buffers in Sun Solaris
Example: ndd -set /dev/tcp tcp_recv_hiwat 65535
[show me the details]
coolcommand: lsvg.sg - script to summarize volume group usage on an IBM AIX server
Example: lsvg.sh
[show me the details]
coolcommand: how to display all the unix groups a user belongs to
Example: id -Gn username; groups username
[show me the details]
coolcommand: ngrep - packet sniffing tool with grep features
Example: ngrep port 80
[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

lvo1151
audet37
kah00na32
Mariom24
lebjf00014

Top 5 Searches

Category Solaris48442
Category AIX44727
Category General UNIX42821
solaris22799
aix21786

Terms of Use
Privacy
Contact


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