This post contains C program to simulate grep command in Linux or Unix operating systems
Simulation of grep command in Linux
#include<stdio.h>
#include<string.h>
main()
{
char fn[10],pat[10],temp[200];
FILE *fp;
printf("Enter file name\n");
scanf("%s",fn);
printf("Enter pattern to be searched\n");
scanf("%s",pat);
fp=fopen(fn,"r");
while(!feof(fp))
{
fgets(temp,1000,fp);
if(strstr(temp,pat))
printf("%s",temp);
}
fclose(fp);
}
Information about resetting and configuring Mobile phones (Java, Android, Symbian etc), educational articles especially for programming in C, C++ and Java and more about Computers and operating systems
C Program to Simulate grep Command in Linux
Labels:
$ccpp
,
c program
,
code
,
command
,
compiled
,
GREP
,
lab
,
Linux
,
operating Systems
,
OS lab
,
programming
,
simulate
,
simulation
,
source code
,
terminal
,
UNIX
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment