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
- The file in jupyter notebook format on github is [here](https://github.com/hiroshi0530/wa-src/blob/master/article/library/bash/unexpand/unexpand_nb . ipynb)
google colaboratory
- If you want to run it in google colaboratory [here](https://colab.research.google.com/github/hiroshi0530/wa-src/blob/master/article/library/bash/ unexpand/unexpand_nb.ipynb)
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$