There are times you need to view the line numbers in a bash script to view script execution.
Within bash ‘set -x’ either at the shell, or within the bash script will display debug output.
To include line numbers you can use the PS4=’${LINENO}:’
The $PS4 variable in Bash is used for the prompt printed before the command line is echoed when the debugging shell option -x is set with the set builtin command
EXAMPLE
#!/bin/bash |
OUTPUT
# ./test.sh + PS4=’${LINENO}: ‘ 6: echo Hello Hello 7: echo World World |