Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How Print a Tab 1

Status
Not open for further replies.

YerMom

Programmer
Oct 3, 2006
127
US
I'm working in tcsh and I have a script that prints information to the console. I would like to have nicely formatted output, with some information separated by tabs, but I don't know how to do this.

How do I output a tab from a script?

Thanks.
 
I don't know tcsh, but in standard shells:
Code:
echo "x[!]\t[/!]y"

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
echo "x\ty" did not work, but printf does:

printf "Some text\tSome more text"

Thanks!
 
For more possibilities in outputting aligned text, explore man page for printf some more

[tt]
printf "%-30.30s %9s %9s\n" FileSystem SIZE FREE
printf "%-30.30s %7.2fGB %7.2fGB\n" /1st/file/system 12.5 1.23
printf "%-30.30s %7.2fGB %7.2fGB\n" /2nd/file/system 4 0.66
printf "%-30.30s %7.2fGB %7.2fGB\n" /3rd/file/system 5.8 1.01
[/tt]

Mostly this needs some trial and error, but it is much easier than tabs as you're not limited to fixed tab stops...


HTH,

p5wizard
 
Thanks a ton Stefan and p5.

I seem to remember all the printf formatting from my C days. (Nice memories.)

Later...

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top