From owner-freebsd-hackers Fri Mar 1 21:49:51 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id VAA10980 for hackers-outgoing; Fri, 1 Mar 1996 21:49:51 -0800 (PST) Received: from seagull.rtd.com (root@seagull.rtd.com [198.102.68.2]) by freefall.freebsd.org (8.7.3/8.7.3) with SMTP id VAA10971 for ; Fri, 1 Mar 1996 21:49:49 -0800 (PST) Received: (from dgy@localhost) by seagull.rtd.com (8.6.12/1.2) id WAA05932 for freebsd-hackers@freefall.cdrom.com; Fri, 1 Mar 1996 22:49:48 -0700 From: Don Yuniskis Message-Id: <199603020549.WAA05932@seagull.rtd.com> Subject: /bin/sh tickler... To: freebsd-hackers@freefall.FreeBSD.org (FreeBSD hackers) Date: Fri, 1 Mar 1996 22:49:48 -0700 (MST) X-Mailer: ELM [version 2.4 PL24] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-hackers@FreeBSD.ORG Precedence: bulk Greetings, Earthlings (and those of you in the back row, too)! Apologies in advance for bothering the list with this one but I couldn't think of a more knowledgable group to pass it by (how's that for "sucking up"???) ;-) I was recently writing a few shell scripts and couldn't seem to find a mechanism for processing tabs within a script! Since tabs are *so* pervasive, I can't imagine this is impossible. Yet, I can't find a way to do it... I started out with something like (not *really* this brainless...): foo=`cat $bar | awk -- '/pattern/ { print "field1 field2" }'` bar=`echo $foo | cut -f2` echo $bar which, curiously, choked because the tab between field1 and field2 had been replaced by a space. Replacing it with a '\t' didn't help, either. In playing with this, I've noted even simpler test cases that yield "unexpected" results: foo="a tab" bar='a tab' echo $foo echo $bar and, different shells respond differently (which, I guess, is to be expected to some degree). I've since found a workaround for my original problem but this one just nags at me begging for understanding. I suspect it has to do with the "substitution" performed by the shell in evaluating these things. But, as I imagine this will bite me again at some time in the future, I'd appreciate any words of wisdom/experience which could help me avoid the same no-brainer mistake in the future. Thx, --don