I currently have two files, one is the main function and another one is core logic. The main function has sourced the code logic and access like a function. But my question had a problem in code logic, how can I view it in debug mode? Below is an example.
Code logic
function logic() {
#!/bin/bash
if [[ -f /tmp/sample.txt ]]; then
echo "hello world"
fi
}
main function file
#!/bin/bash
if [[ -f /tmp/test.txt ]] ; then
logic
echo "Done"
fi
While executing output:
sh -x myscript.sh
++ [[ -f /tmp/test.txt ]]
hello world ## I need debug output here itself.
++ echo "Done"