The Linux core utils package provides two commands called “expand” and “unexpand” to help converting TAB characters to space characters in a file and vice versa.

To convert TAB characters in to space characters:

expand data1.txt

To convert space characters in to TAB characters:

unexpand data2.txt