Warning: Trying to access array offset on value of type bool in /data/www/freeminded.org/www/wp-content/plugins/wp-latex/wp-latex.php on line 39 Bash: echo a tab @ Freeminded.org Warning: Trying to access array offset on value of type bool in /data/www/freeminded.org/www/wp-content/plugins/wp-latex/wp-latex.php on line 46

Bash: echo a tab

This entry was posted by on Wednesday, 15 June, 2011 at

When you’re scripting, you sometimes want nice ‘human readable’ results. Luckily, Bash’s echo command has some formatting tools.

Say you are printing a table, and want the columns separated by tabs:

n     nuppi       tati
1     0.23        0.001
2     0.22        0.004
3     0.20        0.005
...

Simply echo it like this:

echo -e n \\t nuppi \\t tati
... etc

You need the additional escape character (‘\’) in front of the standard tab-character \t, otherwise bash will think it is just a ‘t’.

A similar command in awk:

print n "\t" nuppi "\t" tati;

References:
http://ss64.com/bash/echo.html


Leave a Reply