Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!usc!apple!ames!xanth!cs.odu.edu!Amiga-Request From: Amiga-Request@cs.odu.edu (Amiga Sources/Binaries Moderator) Newsgroups: comp.sources.amiga Subject: v90i044: cat - concatenate files with wildcard matching, Part01/01 Message-ID: <11251@xanth.cs.odu.edu> Date: 2 Feb 90 20:04:54 GMT Sender: tadguy@cs.odu.edu Reply-To: karl@sugar.hackercorp.com (Karl Lehenbauer) Lines: 387 Approved: tadguy@cs.odu.edu (Tad Guy) X-Mail-Submissions-To: Amiga@cs.odu.edu Submitted-by: karl@sugar.hackercorp.com (Karl Lehenbauer) Posting-number: Volume 90, Issue 044 Archive-name: unix/cat This is a reimplementation of the Unix "cat" file concatenator for the Amiga. Unlike the cat supplied by Manx, this cat uses the Manx scdir() function to allow wildcards to be specified. [ uuencoded executable included. ...tad ] -- uunet!sugar!karl "As long as there is a legion of superheros, all else -- can surely be made right." -- Sensor Girl -- Usenet access: (713) 438-5018 #!/bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh 'Makefile' <<'END_OF_FILE' X X Xcat: cat.o X ln cat.o -lc END_OF_FILE if test 27 -ne `wc -c <'Makefile'`; then echo shar: \"'Makefile'\" unpacked with wrong size! fi # end of 'Makefile' fi if test -f 'README' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'README'\" else echo shar: Extracting \"'README'\" \(644 characters\) sed "s/^X//" >'README' <<'END_OF_FILE' X Xcat - concatenate files X XUsage: X X cat [>outfile] file [file..] X XThis program concatenates files specified on the command line and writes Xthe result to standard output, which can then be redirected. X XUnlike the cat distributed with Aztec C, even the brand new 5.0 release, Xthis cat calls scdir so it can do wildcard expansion. X XExample: X X cat >prototypes.h *.pro X XIt could be more fancy (see your nearby System V and BSD manuals for Xpossibilities), but it can do what you usually need it to do. X XThis version of cat is released to the public domain. It is written in XANSI C. X XAuthor: X Karl Lehenbauer (karl@sugar.hackercorp.com) X 1-Feb-1990 END_OF_FILE if test 644 -ne `wc -c <'README'`; then echo shar: \"'README'\" unpacked with wrong size! fi # end of 'README' fi if test -f 'cat.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'cat.c'\" else echo shar: Extracting \"'cat.c'\" \(817 characters\) sed "s/^X//" >'cat.c' <<'END_OF_FILE' X X/* cat - amiga program to concatenate files, requires ANSI C */ X X/* Released to the public domain by Karl Lehenbauer, 1-Feb-1990 */ X X#include X#include X Xvoid catfile(const char *fname) X{ X FILE *fp; X char s[1024]; X X if ((fp = fopen(fname,"r")) == NULL) X { X perror(fname); X return; X } X X while (fgets(s, sizeof(s), fp) != NULL) X fputs(s, stdout); X X if (ferror(fp)) X fprintf(stderr,"cat: error occured reading %s\n",fname); X X fclose(fp); X} X Xmain(int argc, char *argv[]) X{ X char *fname; X int i; X X if (argc < 2) X { X fprintf(stderr,"usage: cat [>outfile] file [file..]\n"); X exit(1); X } X X for (i = 1; i < argc; i++) X while ((fname = scdir(argv[i])) != NULL) X catfile(fname); X X if (ferror(stdout)) X { X fprintf(stderr,"cat: error occured while writing output file\n"); X exit(2); X } X X exit(0); X} END_OF_FILE if test 817 -ne `wc -c <'cat.c'`; then echo shar: \"'cat.c'\" unpacked with wrong size! fi # end of 'cat.c' fi if test -f 'cat.uu' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'cat.uu'\" else echo shar: Extracting \"'cat.uu'\" \(13119 characters\) sed "s/^X//" >'cat.uu' <<'END_OF_FILE' Xbegin 644 cat XM```#\P`````````#``````````(```@N```!!P````$```/I```(+D[Z!MI.2 XM5?O\2.<``$AZ`(`O+0`(3KH$#E!/*T#__&8``!0O+0`(3KH"(%A/3-\``$Y=% XM3G4O+?_\2'@$`$AM^_Q.N@%^3^\`#$J`9P``$DAL@6Y(;?O\3KH"GE!/8-8O9 XM+?_\3KH!2EA/2H!G```6+RT`"$AZ`!Q(;(&$3K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ZN_Y1,WT`$2H!G8 XM+DJK``1NX$AX`0A.N@Q4)$!*@%A/9Q@@2EB((DMP0"#940!724Y$3U<`*@!,] XM[P,```0@"$H89OQ32!#99OQ.=2!O``1P`!(O``L0&+`!5\C_^F<$<`!.=5-($ XM(`A.=4SO`P``!"`((B\`#&`"$-E7R?_\9PP$@0`!``!J\$YU0AA1R?_\!($`B XM`0``:O).=4Y5_?1(YS\R)FT`""QM`!!^`"1M``P6$F8*(`=,WTS\3EU.=5**O XM#`,`)6=")`<@4['K``1D#"!34I,0@W``$`-@#G``$`,O`"\+3KH%+E!/#(#_X XM____9P`$9%*"%A)F!"`"8+A2B@P#`"5FPBX">``K?````"#__!8:<``0`V!F' XM",0``&#R",0``6#L",0``F#F",0``V#@6(XD+O_\2H)L!@C$``!$@A8:8%8KN XM?````##__'0`8!@@`N>`<@`2`]"!T(+0@B0`!((````P%AIP`!`#0>R`5Q`PI XM``!(@`@```)FU&`@5T!GHE]`9Z130&>.54!GA%=`9ZQ@LBM"__@D) XM/```?<8,`P`N9EP6&@P#`"IF%%B.)"[__$J";`8D/```?<86&F`P=`!@&"`"# XMYX!R`!(#T('0@M"")``$@@```#`6&G``$`-![(!7$#```$B`"````F;4#((`. XM`'W&9P@K?````"#__"H"#`,`:&8&",0`!V`6#`,`;&8&",0`!F`*#`,`3&8&V XM",0`"!8:*TH`#'``$`-@``&.8``#&@@$``=G"EB.(&[__#"'8!@(!``&9PI8Q XMCB!N__P@AV`(6(X@;O_\((=T`&```:A8CB1N__PO"DZZ`P@D``R%``!]QEA/7 XM9P:TA6\")`5@``&&6(X6+O__0>W]^"1($(-T`6```7)T"&`0`$0`2'9X=!!@# XM!@C$``1T"@P#`%AF"$'Z`IX@"&`&0?H"IR`(*T#]]`@$``9G"%B.+"[__&`4J XM"`0`!&<(6(XL+O_\8`98CBPN__P(!``$9PI*AFP&1(8(Q``%0>W_^"1(#(4`; XM`'W&9@)Z`4J&9@1*A6<<(@(@!DZZ!:P@;?WT%3`(`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