| 1 | #!/bin/bash |
| 2 | # line-number.sh |
| 3 | |
| 4 | # This script echoes itself twice to stdout with its lines numbered. |
| 5 | |
| 6 | echo " line number = $LINENO" # 'nl' sees this as line 4 |
| 7 | # (nl does not number blank lines). |
| 8 | # 'cat -n' sees it correctly as line #6. |
| 9 | |
| 10 | nl `basename $0` |
| 11 | |
| 12 | echo; echo # Now, let's try it with 'cat -n' |
| 13 | |
| 14 | cat -n `basename $0` |
| 15 | # The difference is that 'cat -n' numbers the blank lines. |
| 16 | # Note that 'nl -ba' will also do so. |
| 17 | |
| 18 | exit 0 |
| 19 | # ----------------------------------------------------------------- |