The nl command is used to show line numbers when viewing a file (unless you use the -b option along with an n, which seems to be one of the more pointless things to ever do at the command line, but then what do I know…). So if you’d like to see the line numbers for a file called xsbackup.sh:
nl xsbackup.sh
The output would look like this:
1 #
2 #!/bin/bash
3 #
4 # Script Name:
Or at least, that’s how I used to do it. For decades I never noticed that cat had a -b option. So if you’d like to use cat to see line numbers in your script, just run the command, along with a -b.
cat -b xsbackup.sh
Cat also allows output lines (-b skips lines with whitespace). Cat also has a squeeze option for sequential lines. Overall, not absolutely everything in nl, but enough that I doubt I’ll need to use nl much in the future.