Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!rutgers!mit-eddie!husc6!seismo!mimsy!cvl!umd5!zben From: zben@umd5.UUCP Newsgroups: comp.unix.questions Subject: Re: some questions about awk Message-ID: <1446@umd5> Date: Mon, 16-Feb-87 22:19:32 EST Article-I.D.: umd5.1446 Posted: Mon Feb 16 22:19:32 1987 Date-Received: Wed, 18-Feb-87 20:20:27 EST References: <254@herman.UUCP> Reply-To: zben@umd5.umd.edu (Ben Cranston) Organization: University of Maryland, College Park Lines: 25 Keywords: awk Summary: Example awk script that outputs control chars In article <254@herman.UUCP> alan@herman.UUCP (Alan Kiecker) writes: > 1. Is there any way to send control codes to the printer from within > an "awk" program. I have not been able to find any way to output > binary, i.e. non-ascii, data from an "awk" program. Both print > and printf insist on converting to ascii. Gosh, it's almost too easy. Use "printf" with a "%c" format and give it a bare integer! Here's a quickie I just whomped up to insert formfeeds every 66 lines for printing "man" entries out on an IBM 3800 laserprinter. awk 'BEGIN { fnam = FILENAME } (fnam!=FILENAME) { NR=1 ; fnam=FILENAME ; printf "%c\n",12 } { print } (65==((NR-1)%66)) { printf "%c\n",12 }' $* Needless to say the 12 is the linefeed. The "fnam" stuff is in case you give it multiple files, it wants to reset (and pageup) between files. There is a bug if you feed it the same file(name) twice. Any REAL awk freaks out there know a solution to this? Kernighan and Pike use this same trick on page 121, with the same bug... -- umd5.UUCP <= {seismo!mimsy,ihnp4!rlgvax}!cvl!umd5!zben Ben Cranston zben @ umd2.UMD.EDU Kingdom of Merryland UniSys 1100/92 umd2.BITNET "via HASP with RSCS"