Converts spaces in the given file to tabs. Print the result to the standard output.

     expand, unexpand -- expand tabs to spaces, and vice versa

     expand [-t tab1,tab2,... ,tabn] [file ...].
     unexpand [-a | -t tab1,tab2,... ,tabn] [file ...]]


google colaboratory


The author’s OS is macOS, and the options are different from those of Linux and Unix commands.

When you actually run the command, the leading ! and %%bash in the first line.

ProductName: Mac OS X
ProductVersion: 10.14.6
BuildVersion: 18G95
!bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin18)
Copyright (C) 2007 Free Software Foundation, Inc.

Example usage

echo -e "a b\nc d" > temp1.txt
cat temp1.txt
a b
c d
unexpand -a -t 3 temp1.txt > temp2.txt
cat -te temp2.txt
cat -te temp2.txt

    a^I b$
    c^I d$