Path: utzoo!attcan!uunet!husc6!uwvax!rutgers!bellcore!tness7!killer!vector!rpp386!jfh From: jfh@rpp386.Dallas.TX.US (The Beach Bum) Newsgroups: news.admin Subject: Re: A solution to the dilemma Summary: oops, forgot the C program Message-ID: <6830@rpp386.Dallas.TX.US> Date: 19 Sep 88 12:17:20 GMT References: <6817@rpp386.Dallas.TX.US> <6818@rpp386.Dallas.TX.US> Reply-To: jfh@rpp386.Dallas.TX.US (The Beach Bum) Distribution: world,!to.portal Organization: HASA, "S" Division Lines: 41 In article <6818@rpp386.Dallas.TX.US> jfh@rpp386.Dallas.TX.US (The Beach Bum) writes: >i have created a little shell script which seeks out portal postings >and cancels them. which requires the C program below ... [ or a grep command, either way ] -- gethead.c -- #includemain (argc, argv) int argc; char **argv; { char filename[BUFSIZ]; char line[BUFSIZ]; int i; FILE *fp; if (argc < 2) exit (1); i = strlen (argv[1]); while (gets (filename) != (char *) 0) { if ((fp = fopen (filename, "r")) == (FILE *) 0) continue; while (fgets (line, BUFSIZ, fp) == line) { if (strncmp (line, argv[1], i) == 0) { fprintf (stdout, "%s: %s", filename, line); break; } } fclose (fp); } } -- end of gethead.c -- -- John F. Haugh II (jfh@rpp386.Dallas.TX.US) HASA, "S" Division "If the code and the comments disagree, then both are probably wrong." -- Norm Schryer