[svlug] How to print a tab with echo? (fwd)
Rick Kwan
kenobi at lightsaber.com
Tue Jul 25 07:08:01 PDT 2000
I know what I did wrong.
I just saw the post from Greg Olszewski <noop at nwonknu.org>. From
bash, if I use "echo -e" instead of "echo", everything works fine.
"tcsh" does not use "-e"; nor does Solaris "sh" or "csh".
...it's too early in the morning for shell shock... :-(
--Rick Kwan
---------- Forwarded message ----------
Date: Tue, 25 Jul 2000 06:53:05 -0700 (PDT)
From: Rick Kwan <kenobi at lightsaber.com>
To: svlug at lists.svlug.org
Cc: yuwen at microtek.com.cn, deirdre at deirdre.net
Subject: Re: [svlug] How to print a tab with echo?
On Mon, 24 Jul 2000, Deirdre Saoirse wrote:
> On Mon, 24 Jul 2000, Rick Kwan wrote:
>
> > The shell which invokes "echo" reads the tab as just white space.
>
> Is it possible that \t makes a tab? A lot of this stuff escapes characters
> in similar ways and that's what's used in C (and other languages).
>
> > "Dai Yuwen" <yuwen at microtek.com.cn> wrote:
> > > I want to print a tab in a echo statement, like this:
> > >
> > > echo file description >> list
> > > ^^^^
> > > here is a tab key
Looking at the GNU bash and Solaris (as far back as 2.4) sh man
pages, I would believe Deirdre is correct. In fact, I just looked
up some old System III books; one would think that it worked then.
However... I just tried the following example with two different
shells:
==== example "trythis" below ====
#!/bin/sh
echo file description
echo file "\t" description
echo "file\tdescription"
==== example "trythis" above ====
The first line has a tab between "file" and "description".
With "bash trythis", I got
==== bash results below ====
file description
file \t description
file\tdescription
==== bash results above ====
With "tcsh trythis", I got
==== tcsh results below ====
file description
file description
file description
==== tcsh results above ====
I used to not use "\t" with "echo" because of portability concerns.
15 minutes ago, I was about to switch... until I saw this.
Any explanations? (BTW, I got the same results for RH 5.1 and
RH 6.1.)
--Rick Kwan, Lightsaber Computing
rick.kwan at lightsaber.com
More information about the svlug
mailing list