write a program to display all the files from the current
directory which are created in particular month

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the conditional statement in shell scripting?

661


What does debug script mean?

555


What are the different types of variables used in shell script?

556


What does $@ mean in shell?

594


What is the use of "$#" in shell scripting?

553






What is web script?

586


is this growing field and what is average package in this?

1876


Print a given number, in reverse order using a shell script such that the input is provided using command line argument only.

705


What is bash eval?

551


Please give me example of " at command , contrab command " how to use

2331


Can we run shell script in windows?

583


How to get script name inside a script?

556


Write a command sequence to find the count of each word?

542


What are the different commands available to check the disk usage?

497


How to find all the files modified in less than 3 days and save the record in a text file?

615