layout | title | tags |
---|---|---|
manual |
cat -s || Squeeze the empty lines to one line |
cat |
When using a command line interface of mac machine, we use command cat
to look inside a file.
s
is the abbreviation of squeeze
.
Squeeze multiple adjacent empty
lines, causing the output to be single spaced.
This option squeezes the empty lines in just one single spaced line. However, the definition of empty
need to be addressed here.
Sometimes, when using option -s
, none of the empty lines are squeezed. This is because there is still something
in the line. It could be a space
or a tab
. They can't be seen by human but they can be seen by the machines. So it's not completely empty.
Mac (BSD) command line utilities
Here is the example of cat -sn
.
- Let's create a file (file1.sh) for testing option
-s
.
# the content of file1.sh
1 echo "file1"
2 # completely blank
3 # a tab
4 # completely blank
5 # a tab
6 echo "file1"
cat -sn
Squeeze the empty lines to one line. Option-n
helps to number the output lines.
$cat -sn file1.sh
1 echo "file1"
2
3
4
5
6 echo "file1"