Linux ]}“有你所有的文件,当然要使你的for循环适应这种语法。是的,我的脚本按照你说的方式排列在一个数组中。例如,我的数组现在有6个脚本。输出不比较script2-script3、script2-script4、script2-script5、script2-

Linux ]}“有你所有的文件,当然要使你的for循环适应这种语法。是的,我的脚本按照你说的方式排列在一个数组中。例如,我的数组现在有6个脚本。输出不比较script2-script3、script2-script4、script2-script5、script2-,linux,bash,sh,Linux,Bash,Sh,]}“有你所有的文件,当然要使你的for循环适应这种语法。是的,我的脚本按照你说的方式排列在一个数组中。例如,我的数组现在有6个脚本。输出不比较script2-script3、script2-script4、script2-script5、script2-script6和其他一些比较。它只在我的数组有5个脚本时才起作用,我的目的是将代码用于一个脚本数量不确定的数组。因此,我正在寻找如何将此代码正确地用于包含5个以上脚本的数组。 script1-script2 script1-script3 sc


]}“有你所有的文件,当然要使你的for循环适应这种语法。是的,我的脚本按照你说的方式排列在一个数组中。例如,我的数组现在有6个脚本。输出不比较script2-script3、script2-script4、script2-script5、script2-script6和其他一些比较。它只在我的数组有5个脚本时才起作用,我的目的是将代码用于一个脚本数量不确定的数组。因此,我正在寻找如何将此代码正确地用于包含5个以上脚本的数组。
script1-script2
script1-script3
script1-script4
script2-script3
script2-script4
script3-script4
and so on...
echo "NUMBER OF TOTAL LINES";
for i in "${script[@]}"
do
cat $i | wc -l
done
echo "NUMBER OF COMMENTS";
for i in "${script[@]}"
do
grep -o '#' $i | wc -l
done 
echo "NUMBER OF IF COMMANDS"
for i in "${script[@]}"
do
grep -o 'if' $i | wc -l
done
NUMBER OF TOTAL LINES
12
19
70
NUMBER OF COMMENTS
4
5
8
NUMBER OF IF COMMANDS
3
0
2
the script1 has 12 lines and the script2 has 19 lines
the script1 has 12 lines and the script3 has 70 lines
the script2 has 19 lines and the script3 has 70 lines

the script1 has 4 comments and the script2 has 5 comments
the script1 has 4 comments and the script3 has 8 comments
the script2 has 5 comments and the script3 has 8 comments

the script1 has 3 if commands and the script2 has 0 if commands
the script1 has 3 if commands and the script3 has 2 if commands
the script2 has 0 if commands and the script3 has 2 if commands