From owner-freebsd-questions Mon Mar 4 23:58:15 1996 Return-Path: owner-questions Received: (from root@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id XAA00352 for questions-outgoing; Mon, 4 Mar 1996 23:58:15 -0800 (PST) Received: from mail.EUnet.hu (mail.eunet.hu [193.225.28.100]) by freefall.freebsd.org (8.7.3/8.7.3) with ESMTP id XAA00317 for ; Mon, 4 Mar 1996 23:58:06 -0800 (PST) Received: by mail.EUnet.hu, id IAA07157; Tue, 5 Mar 1996 08:57:33 +0100 Received: by CoDe.CoDe.hu (NAA02650); Mon, 4 Mar 1996 13:51:21 GMT From: Gabor Zahemszky Message-Id: <199603041351.NAA02650@CoDe.CoDe.hu> Subject: Re: stewpid shell tricks To: dgy@rtd.com (Don Yuniskis) Date: Mon, 4 Mar 1996 13:51:21 +0000 (GMT) Cc: freebsd-questions@freebsd.org In-Reply-To: <199603011529.IAA15089@seagull.rtd.com> from "Don Yuniskis" at Mar 1, 96 08:29:21 am X-Mailer: ELM [version 2.4 PL24] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-questions@freebsd.org Precedence: bulk > > Greetings! > Can someone explain how to properly embed tabs in shell variables > and commands? As a real simplistic test case: > > x="this\tis a test" > echo $x > > yields different results under different shells. In particular, I > haven't found a good way of doing: > > result=`echo $x | cut -f2` > > or similar. > Thx, > --don First: try echo "$x" (or printf) If you don't put ", the shell substitues the $x, but in it, there is a character, which will be a separatot character, so the echo command will get 2 parameters, and generates a line in which there will be a space between them. (and not a tab character) Second you can put tabs in the variables: x='something' or instead of ', you can use ". Or maybe: some\thing works, too. Of course, hit . Some shells (bash, zsh, ksh, and FB's sh in command-line editing modes, sometimes use the character. Most times, you can type Ctrl-V, and after it a in that is your problem. Or write me more clean, what is the problem -- Gabor Zahemszky -:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:- Earth is the cradle of human sense, but you can't stay in the cradle forever. Tsiolkovsky