layout | title | tags |
---|---|---|
manual |
cat -b || Clear definition of blank when using option -b of command cat |
cat |
When using a command line interface of mac machine, we use command cat
to look inside a file.
b
is the abbreviation of blank
.
Number the non-blank output lines, starting at 1.
This option ignores the blank output lines and delivers a neat print out. However, the definition of blank
need to be addressed here.
Sometimes, when using option -b
, you still see a blank
line with a line number at the very beginning. 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 blank.
Mac (BSD) command line utilities
Here is the example of cat -b
.
- Let's create a file (file1.sh) for testing option
-b
.
# the content of file1.sh
1 echo "file1"
2 # completely blank
3 # a tab
4 # completely blank
5 # a tab
6 echo "file1"
cat -b
Number the non-blank output lines, starting at 1.
$cat -b file1.sh
1 echo "file1"
2
3
4 echo "file1"