Setting the tab-width in a linux-shell

If you don’t use the same tab-width whithin all your favourite applications then the following might happen from time to time:

mail:/tmp# cat /etc/crontab

0  *  *  *  *     root     /usr/bin/php /root/bin/check_open_ports.php
5    2  *  *  *    root    /root/bin/wittnet_check.sh
18    22  *  *  *    root     /root/bin/check_sites.sh
0     19  *  *  *    root     /root/bin/check_diskspace.sh
0    6  *  *  *    root     /root/bin/daily_db_backup.sh
0      6  *  *  *    root     /root/bin/postgresql_backup.sh
0      7  *  *  *    root     /root/bin/ics/start.sh
0    0  *  *  *    root     /root/bin/learn_spam.sh

This is the output of a crontab which was usually modified by vi(m) and because of the different indentations this looks really bad. In vim i’m using a tab-width of 4 characters, in the shell my tab-width is … unknown!

Unknown until now – I’ve found the tabs command which takes one parameter and this parameter is the size of a tabulator in chars. With tabs it’s easy to set the tab-width in a shell which will be used by programs like cat, tail, …

mail:/tmp# tabs 4
mail:/tmp# cat /etc/crontab

0   *   *  *  *    root     /usr/bin/php /root/bin/check_open_ports.php
5    2  *  *  *    root     /root/bin/wittnet_check.sh
18  22  *  *  *    root     /root/bin/check_sites.sh
0   19  *  *  *    root     /root/bin/check_diskspace.sh
0    6  *  *  *    root     /root/bin/daily_db_backup.sh
0    6  *  *  *    root     /root/bin/postgresql_backup.sh
0    7  *  *  *    root     /root/bin/ics/start.sh
0    0  *  *  *    root     /root/bin/learn_spam.sh

Now everything look’s fine and it’s easier to read this crontab as it was before.

Leave a Reply

Your email address will not be published. Required fields are marked *


*