Loads a file and converts tabs to spaces.


  • The file in jupyter notebook format on github is here

google colaboratory

  • To run it on google colaboratory here expand/expand_nb.ipynb)


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

expnad <option> filen_ame

Typical options

  • [-t N] : Specifies the number of tabs to convert.

t option.

Creates a file with tabs.

echo -e "1\t2\t3" > temp.txt # echo -e to insert tabs into the file.
cat -t temp.txt # Make the tabs visible with cat -t.
expand -t 5 temp.txt
1 2 3

Reference article