1832898 Members
2648 Online
110048 Solutions
New Discussion

How to make echo tab?

 
SOLVED
Go to solution
Edward McCouch
Frequent Advisor

How to make echo tab?

Hi all,

I'm writing a little shell script for adding remote printers and want the questions tabbed away from the left side of the screen. I know that I can accomplish this with the following line.

echo " Text goes here"

I tried looking at the man page for echo and it says to use \t for tab. I tried that and this is what happened.

echo \t "Text goes here"
t Text goes here

Can anyone help me out? OS is HP-UX 11.11
3 REPLIES 3
Rodney Hills
Honored Contributor
Solution

Re: How to make echo tab?

Try putting \t in the quotes-

echo "\tText goes here"

HTH

-- Rod Hills
There be dragons...
A. Clay Stephenson
Acclaimed Contributor

Re: How to make echo tab?

You need to enclose the \t within quotes:
echo "\tText goes here"

Often you want to echo without a newline as well; the trick here is "\c" also with the quotes.
echo "\tText on same line\c"
echo " More text on the same line"

The second example line emits an implicit LF while the first line suppresses it using \c.
Man echo for details.
If it ain't broke, I can fix that.
Edward McCouch
Frequent Advisor

Re: How to make echo tab?

Thank you for the quick replies. I feel a little silly for not thinking of putting the \t in the quotes.

-Ed