write a program to display all the files from the current
directory which are created in particular month
Answers were Sorted based on User's Feedback
Answer / rakesh
#include<stdio.h>
#include<stddef.h>
#include<dirent.h>
#include<string.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<time.h>
#include<stdlib.h>
int main(int argc,char *argv[])
{
char in[100],st[100],*ch,*ch1,c,buff[512];
DIR *dp;
int i;
struct dirent *ep;
struct stat sb;
char mon[100];
dp=opendir("./");
if(dp!=NULL)
{
while(ep=readdir(dp))
{
if(stat(ep->d_name,&sb)==-1)
{
perror("stat");
exit(EXIT_SUCCESS);
}
strcpy(mon,ctime(&sb.st_ctime));
ch=strtok(mon," ");
ch=strtok(NULL,",");
ch1=strtok(ch," ");
if((strcmp(ch1,argv[1]))==0)
{
printf("%s \t\t %s",ep->d_name,ctime(&sb.st_ctime));
}
}
(void)closedir(dp);
}
return 0;
}
Is This Answer Correct ? | 3 Yes | 0 No |
Answer / geichel
Create time is not kept in the inode. Times for Access,
Modify, and Change is all you get.
Is This Answer Correct ? | 1 Yes | 1 No |
Answer / pitambar mishra
Mr. Rakesh,
It is a unix forum. You have written the program in C language. Please convert the program in to shell script.
Ans:
ls -l|grep -i sep
ls -l|awk '/Sep/ {print}'
ls -l|sed -n '/Sep/ p'
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / dejan
This is a tricky question. You are able to see only
Access: 2010-12-08 09:36:52.000000000 +0100
Modify: 2010-12-07 13:20:16.000000000 +0100
Change: 2010-12-07 13:20:16.000000000 +0100
There is no "create field"
Is This Answer Correct ? | 1 Yes | 2 No |
Answer / sathish kumar p
echo "Enter the month name"
read Month
ls -lt | grep $Month
Is This Answer Correct ? | 2 Yes | 4 No |
how to find weblogic version through linux cammand
what is the difference between cmp and diff commands
what is info area how many types?
What are the different commands available to check the disk usage?
write a shell script to identify the given string is palindrome or not?
17 Answers CTS, HP, IBM, InfoEst, Wipro,
write a scwipt that a) takes exactly one argument, a directory name. b) if the number of argument is more or less than one,print a usage message c) if the argument is not adirectory, print another message d) for the given directory, print the five biggest files and the five files that were most recently modified. e) save the output to a file called q2output.
How do I edit a .sh file?
How do I debug a shell script?
There are three departments A,B and C.Write a query to display the names of all the persons( in departments other than A) who are paid higher than the person receiving the lowest salary in DEPT A
madhar chod unix ke 10 commands dhang se likh nahi sakta hai
Tell something about the super block in shell scripting?
Is shell scripting a language?