I inherited a over 700 line shell script and noticed that when I ran the script it spits out error at some point of execution.
E.g error that I see on the console is something like
cat: /Wreck/wreck_module.rb: No such file or directory
I have tried to use set -x
and most of the tips from this link, however I noticed that all the output that I was getting were pretty noisy.
Is there a way to get the exact line number of where a shell command returned a non-zero status?
Put this at the top of the script you want to debug:
#!/bin/bash
function trace_line(){
caller
}
trap trace_line debug
and perhaps redirect the output to a file for easy analysis.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With