From owner-freebsd-questions Tue Aug 6 13:09:56 1996 Return-Path: owner-questions Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id NAA17379 for questions-outgoing; Tue, 6 Aug 1996 13:09:56 -0700 (PDT) Received: from hod.tera.com (hod.tera.com [206.215.142.67]) by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id NAA17366 for ; Tue, 6 Aug 1996 13:09:50 -0700 (PDT) Received: from athena.tera.com (athena.tera.com [206.215.142.62]) by hod.tera.com (8.7.5/8.7.3) with ESMTP id NAA04539; Tue, 6 Aug 1996 13:09:16 -0700 (PDT) From: Gary Kline Received: (from kline@localhost) by athena.tera.com (8.7.5/8.7.3) id NAA11413; Tue, 6 Aug 1996 13:09:15 -0700 (PDT) Message-Id: <199608062009.NAA11413@athena.tera.com> Subject: Re: ``tgrep'' from Unix Power Tools To: fqueries@jraynard.demon.co.uk (James Raynard) Date: Tue, 6 Aug 1996 13:09:15 -0700 (PDT) Cc: kline@tera.com, questions@freebsd.org In-Reply-To: <199608061014.KAA01581@jraynard.demon.co.uk> from James Raynard at "Aug 6, 96 10:14:13 am" 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 According to James Raynard: > > > > Has anyone used the short `tgrep' perl script from the UNIX > > POWER TOOLS book? It works on my Sun and fails with a strange > > error blurb on my FreeBSD machine. > > > > tgrep grep only text file, skipping directories and binaries. > > If it's the same tgrep as the one in the "Camel book", I'm sure it > ought to work. Could you post a copy of it and tell us what the > exact error message is? > > In case people are curious, below are the 40 lines; with debugging: ~/bin #!/usr/local/bin/perl # Usage: tgrep [-l] pattern [files] # Handle if ($ARGV[0] eq '-l') { shift; $action = <<'EOF'; print $file,"\n"; next FILE; EOF } else { $action = <<'EOF'; print $file,":\t", $_; EOF } # Get pattern and protect the delimiter we'll use. $pat = shift; $pat =~ s/!/\\!/g; # Generate the program. $prog = <) { if (m!$pat!) { $action } } } EOF # We often put in lines like this while developing scripts, so we # can see what program the program is writing. print $prog if $debugging; # And finally, do it. eval $prog; die $@ if $@; From the debug is this: -T and -B not implemented on filehandles at (eval) line 7. and the reason, as Nate Williams explained, is that our version of stdio doesn't check for binary file types. gary