Skip to content

Latest commit

 

History

History
50 lines (38 loc) · 1.33 KB

cat_s.md

File metadata and controls

50 lines (38 loc) · 1.33 KB
layout title tags
manual
cat -s || Squeeze the empty lines to one line
cat

Scenario

When using a command line interface of mac machine, we use command cat to look inside a file.

Options -s for cat

s is the abbreviation of squeeze.

Manpage Description

Squeeze multiple adjacent empty lines, causing the output to be single spaced.

Detail Explain

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.

Version

Mac (BSD) command line utilities

Examples

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"