In Bash, you can see
set --help
-x Print commands and their arguments as they are executed.
Here's test code:
# make script
echo '
#!/bin/bash
set -x
n=$(echo "a" | wc -c)
for i in $(seq $n)
do
file=test_$i.txt
eval "ls -l | head -$i"> $file
rm $file
done
' > test.sh
# execute
chmod +x test.sh
./test.sh 2> stderr
# check
cat stderr
Output
+++ echo a +++ wc -c ++ n=2 +++ seq 2 ++ for i in $(seq $n) ++ file=test_1.txt ++ eval 'ls -l | head -1' +++ ls -l +++ head -1 ++ rm test_1.txt ++ for i in $(seq $n) ++ file=test_2.txt ++ eval 'ls -l | head -2' +++ ls -l +++ head -2 ++ rm test_2.txt
What is the meaning of the number of + signs at the beginning of each row in the file? It's kind of obvious, but I want to avoid misinterpreting.
In addition, can a single + sign appear there? If so, what is the meaning of it?