As illustrated in the other answers, the tabs
utility is the simpler way to specify tab stops for applications (such as your shell) which do not set their own tab stops. POSIX specifies a tabs
utility, (as well as tput
), but has nothing to say about terminfo or the behavior of tput
for this purpose. (X/Open Curses, which is a separate standard, does have something to say).
But to use those tab stops, you should also ensure that your terminal is setup to use hardware tabs. If you do stty -a
, look for tab0
in the output:
speed 38400 baud; rows 40; columns 80; line = 0;
intr = ^C; quit = ^\; erase = ^H; kill = ^U; eof = ^D; eol = <undef>;
eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd cs8 -hupcl -cstopb cread -clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff
-iuclc -ixany -imaxbel -iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
echoctl echoke
According to the stty
manual, you should be able to set tab0
or tab3
. POSIX defines tab1
and tab2
, but only tab0
(hardware tabs) and tab3
(software tabs) are useful to you.
tab0 tab3
Select tab expansion policy. tab0
disables tab expansion, while tab3
enables it.
Further reading:
./a.out
or whatever is the name of the binary. – yo' Oct 24 '12 at 16:45./a.out > file.txt
, then the file contains the tab character. So obviously, the program sends the tab character to the terminal and it's a role of the terminal to typeout it correctly. – yo' Oct 24 '12 at 17:20