unexpand

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

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

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

github

google colaboratory

environment

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.

!sw_vers
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

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

    a^I b$
    c^I d$