%%s 8/3/110 %%d D 1.2 26-Apr-82 06:27:54 j 2 1 %%c Modified cat.w`cat.r`caten8 to append a dollar sign ('$') to each line %%c to aid in location of trailing blanks when in verbose mode. %%c %%c Modified cat.w`cat.fmt to reflect this change. %%s 0/0/0 %%d D 1.1 25-Mar-82 12:02:23 v1.1 1 0 %%c Version 1.1 is the Spring 1982 Distribution of the LBL/Hughes release %%c of the Software Tools Virtual Operating System software and documentation. %%T %%I 1 %%D 2 #-h- cat.r 1562 asc 25-mar-82 07:23:48 v1.1 (sw-tools v1.1) %%E 2 %%I 2 #-h- cat.r 1606 asc 26-apr-82 06:26:35 j (sventek j) %%E 2 #-h- main 930 asc 25-mar-82 07:23:38 v1.1 (sw-tools v1.1) ## cat - concatenate named files onto standard output DRIVER(cat) character buf(MAXLINE) integer getarg, open integer i, int, verbos, nf ifdef(BKY) integer gettyp, ovride, junk enddef call query("usage: cat [-v] [file] ...") verbos = NO nf = 0 for (i=1; getarg(i, buf, MAXLINE) != EOF; i=i+1) { if (buf(1) == '-') if (buf(2) == EOS) int = STDIN else { if (buf(2) == 'v' | buf(2) == 'V') verbos = YES else call badarg(buf) next } else int = open(buf, READ) if (int == ERR) call cant(buf) ifdef(BKY) #For BKY, set stdout type to that of first input file, unless overridden if (i == 1 & ovride(STDOUT) == NO) call settyp(STDOUT, gettyp(int,junk)) enddef nf = nf + 1 call caten8(int, STDOUT, verbos) if (int != STDIN) call close(int) } if (nf == 0) # no file arguments call caten8(STDIN, STDOUT, verbos) DRETURN end %%D 2 #-h- caten8 486 asc 25-mar-82 07:23:38 v1.1 (sw-tools v1.1) %%E 2 %%I 2 #-h- caten8 537 asc 26-apr-82 06:20:17 j (sventek j) %%E 2 ## caten8 - copy in to out, expanding control characters if verbos == YES ## this routine assumes that the characters are ASCII - do not subvert!! subroutine caten8(in, out, verbos) filedes in, out integer verbos character c character getch while (getch(c, in) != EOF) { if (verbos == YES) if (c != '@n' & (c < ' ' | c == DEL)) { call putch('^', out) if (c == DEL) c = '?' else c = c + '@@' } %%I 2 else if (c == '@n') call putch('$', out) %%E 2 call putch(c, out) } return end %%D 2 #-h- cat.fmt 956 asc 25-mar-82 07:23:50 v1.1 (sw-tools v1.1) %%E 2 %%I 2 #-h- cat.fmt 1072 asc 26-apr-82 06:26:37 j (sventek j) %%E 2 .so ~bin/manhdr .hd Cat (1) 16-Feb-78 concatenate and print text files .sy cat [-v] [file] ... .ds `cat' reads each file in sequence and writes it on the standard output. Thus .sp 1 .ti +5 cat file .sp 1 prints the file, and .sp 1 .ti +5 cat file1 file2 >file3 .sp 1 concatenates the first two files and places the result on the third. .sp 1 If no argument or '-' is given, `cat' reads the standard input. %%I 2 %%E 2 If the '-v' option is specified, all control characters are displayed as '^C', where C is the character that must be typed with the CTRL key when entering the character. If any DEL(RUB) characters are found, they are displayed as '^?'. %%I 2 A dollar sign character ('$') is displayed at the end of each line to aid in location of trailing blanks in lines. %%E 2 .fl none .sa The "Software Tools" book, p. 77. .br The UNIX tools cat, PR, CP .di A message is printed if a file cannot be opened; further processing is terminated. .au Dennis Hall, Debbie Scherrer and Wen-Sue Gee. .bu Using the same file for output as well as input may cause strange results. %%E 1