How do I print line numbers in shell script?

Giao Linh

New member
How do I print line numbers in shell script?
Answer
You can change PS4 to emit the LINENO (The line number in the script or shell function currently executing). In Bash, $LINENO contains the line number where the script currently executing. If you need to know the line number where the function was called, try
$BASH_LINENO. Note that this variable is an array.
 

Tìm kiếm

Back
Top