Running Ubuntu16.04 I would like to display in the terminal the line number in a running bash script.
It would be something like this example if it was in php:
echo "Installing NGINX. Line: ".__LINE__
How could I translate it to bash?
Running Ubuntu16.04 I would like to display in the terminal the line number in a running bash script.
It would be something like this example if it was in php:
echo "Installing NGINX. Line: ".__LINE__
How could I translate it to bash?
In
bash
you can use the variable$LINENO
for this purpose:$LINENO
holds the current line number, seeman bash
:Example
When executed this script prints: