home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 8 Other
/
08-Other.zip
/
OS2MNX1.ZIP
/
CAT2.C
< prev
next >
Wrap
Text File
|
1989-12-26
|
2KB
|
54 lines
/* $Header: D:/RCS/RCS/cat2.c 1.1 89/12/24 07:55:37 RCA Exp $
* $Log
*/
#include <stdio.h>
#include <stdlib.h>
void filecopy(FILE *);
main(argc, argv) /* cat: concatenate files */
int argc;
char *argv[];
{
FILE *fp, *fopen();
if (argc == 1)
{
printf ("\n █▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀█");
printf ("\n █ CAT2 (Concatenate) $Author: RCA $ █");
printf ("\n █ $Date: 89/12/24 07:55:37 $ $Revision: 1.1 $ █");
printf ("\n █ Usage: CAT2 file1 file2 [ ... file(n)] > outfile █");
printf ("\n █ Purpose: This command concatenates two or more files and █");
printf ("\n █ then copies them to standard output. Can be █");
printf ("\n █ used to append CRLF's to UNIX files. █");
printf ("\n █ OS: Works under OS/2 or DOS. █");
printf ("\n █ Credits: From Kernighan & Ritchie, p. 154. █");
printf ("\n █▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█\n");
exit(1);
}
/* if (argc == 1) \\ no args; copy standard input */
/* filecopy(stdin); */
else
while (--argc > 0)
if ((fp = fopen(*++argv, "r")) == NULL) {
fprintf(stderr,
"cat: can't open %s\n", *argv);
exit(1);
} else {
filecopy(fp);
fclose(fp);
}
exit(0);
}
void filecopy(fp) /* copy file fp to standard output */
FILE *fp;
{
int c;
while ((c = getc(fp)) != EOF)
putc(c, stdout);
}