Use $LINENO to get the current line number in a bash script
The $LINENO
variable always holds the number of the current line in a bash script.
Consider the following script:
#!/usr/bin/env bash
echo "Hello from line $LINENO!"
Then, when you execute it, you’ll get:
$ ./test.sh
Hello from line 3!