Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 4 Mar 1996 13:51:21 +0000 (GMT)
From:      Gabor Zahemszky <zgabor@CoDe.hu>
To:        dgy@rtd.com (Don Yuniskis)
Cc:        freebsd-questions@freebsd.org
Subject:   Re: stewpid shell tricks
Message-ID:  <199603041351.NAA02650@CoDe.CoDe.hu>
In-Reply-To: <199603011529.IAA15089@seagull.rtd.com> from "Don Yuniskis" at Mar 1, 96 08:29:21 am

next in thread | previous in thread | raw e-mail | index | archive | help
> 
> 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 <tab> 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='some<tab>thing'
or instead of ', you can use ".  Or maybe: some\<tab>thing
works, too.
Of course, hit <TAB>.  Some shells (bash, zsh, ksh, and FB's sh
in command-line editing modes, sometimes use the <TAB> character.
Most times, you can type Ctrl-V, and after it a <TAB> in that is your
problem.  
Or write me more clean, what is the problem


-- 
	Gabor Zahemszky <zgabor@CoDe.hu>

-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-
Earth is the cradle of human sense, but you can't stay in the cradle forever.
						Tsiolkovsky



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199603041351.NAA02650>