It is possible to make the following bash script to work as I said in the title?
#!/bin/bash echo_report() { echo "echo on line $1" } trap 'echo_report $LINENO' [sigspec] #same code here echo "hi" #more code here I don't know what should I use for [sigspec]...
If using trap is not possible, what other options do I have?
echo "hi"grep -n "echo" myscript.sh?kill -SIGUSR1 $$and your trap would betrap 'echo_report $LINENO' SIGUSR1DEBUGsignal, but that is non-selective; it is triggered by (just about) every command, not just, say,echocommands.