2001-07-10 14:25:50 +00:00
|
|
|
#!/bin/bash
|
2005-03-21 13:51:11 +00:00
|
|
|
# line-number.sh
|
2001-07-10 14:25:50 +00:00
|
|
|
|
2001-09-04 13:27:31 +00:00
|
|
|
# This script echoes itself twice to stdout with its lines numbered.
|
2001-07-10 14:25:50 +00:00
|
|
|
|
2012-11-27 14:56:18 +00:00
|
|
|
echo " line number = $LINENO" # 'nl' sees this as line 4
|
|
|
|
# (nl does not number blank lines).
|
|
|
|
# 'cat -n' sees it correctly as line #6.
|
2001-07-10 14:25:50 +00:00
|
|
|
|
|
|
|
nl `basename $0`
|
|
|
|
|
|
|
|
echo; echo # Now, let's try it with 'cat -n'
|
|
|
|
|
|
|
|
cat -n `basename $0`
|
|
|
|
# The difference is that 'cat -n' numbers the blank lines.
|
|
|
|
# Note that 'nl -ba' will also do so.
|
|
|
|
|
|
|
|
exit 0
|
2003-11-03 16:25:16 +00:00
|
|
|
# -----------------------------------------------------------------
|