From owner-freebsd-questions Tue May 27 05:06:26 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id FAA10198 for questions-outgoing; Tue, 27 May 1997 05:06:26 -0700 (PDT) Received: from mail.EUnet.hu (www.eunet.hu [193.225.28.100]) by hub.freebsd.org (8.8.5/8.8.5) with ESMTP id FAA10188 for ; Tue, 27 May 1997 05:06:23 -0700 (PDT) Received: by mail.EUnet.hu, id OAA18646; Tue, 27 May 1997 14:06:04 +0200 Received: (from zgabor@localhost) by CoDe.hu (8.7.5/8.7.3) id MAA00626; Tue, 27 May 1997 12:19:33 +0200 (MET DST) From: Zahemszky Gabor Message-Id: <199705271019.MAA00626@CoDe.hu> Subject: Re: print filter To: freebsd-questions@freebsd.org (FreeBSD questions) Date: Tue, 27 May 1997 12:19:32 +0200 (MET DST) Cc: un_x@anchorage.net In-Reply-To: from Steve Howe at "May 22, 97 05:52:05 pm" X-Mailer: ELM [version 2.4ME+ PL11 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-questions@freebsd.org X-Loop: FreeBSD.org Precedence: bulk > > this is an "auto" bsd/dos lp filter i whipped up ... > can anyone tell me why it prints a blank line at the > beginning of each document (not page, document ...)? Well, I tried it but I don't know. Maybe your laziness about "-s, or some bug in sh, I don't know. Instead of if [ .. ] , try eliminating the test, and the backtick. if echo "$line1" | grep -q '^M' ; then ... (Well, in 2.1.5, the -q option of grep isn't documented in the synopsis of the grep manual, only in the long description). Of course, this version is cheaper with two forks/one exec (with one/zero, if [ is a builtin command in sh), and some builtin redirection because of the `. So I don't know, if it works, but if not, you tuned your machine's performance, at least. ;-) > ------------------------------------------------------------------------- > #!/bin/sh > # > # simple lp text filter (BSD/DOS) > > read line1 > > if [ `echo $line1|grep ^M` ]; then > echo $line1 && cat && echo ^L && exit 0 > else { echo $line1 && cat; } | sed s/$/^M/ && echo ^L && exit 0 > fi > exit 2 Gabor -- #!/bin/ksh Z='21N16I25C25E30, 40M30E33E25T15U!' ;IFS=' ABCDEFGHIJKLMNOPQRSTUVWXYZ ';set $Z;for i { [[ $i = ? ]]&&print $i&&break;[[ $i = ??? ]]&&j=$i&&i=${i%?};typeset -i40 i=8#$i;print -n ${i#???};[[ "$j" = ??? ]]&&print -n "${j#??} "&&j=;typeset +i i;};IFS=' 0123456789 ';set $Z;X=;for i { [[ $i = , ]]&&i=2;[[ $i = ?? ]]||typeset -l i;X="$X $i";typeset +l i;};print "$X"