I am writing a considerably huge shell script. Is there any way to print the line number of the script from that script? Basically I want to have something similar to gcc LINE macro. This will help me to debug my script.
Thanks in advance,
Souvik
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Had to do it myself a while ago and found this useful article back then: http://aymanh.com/how-debug-bash-scripts#adding-line-numbers-to-tracing-output
Essentially you need to use
$LINENOto get the current line in the script.