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!