I have a list of shell scripts (that end with .sh) in a folder and I am trying to make a list of them, and the list should have two script names (separated by a space) in each line. I wrote the following script, but it does not work without showing any errors. I was hoping to get some help here:
file1=""
for file in $(ls ./*.sh); do
i=1
file1="$file1$file "
if [ $i -lt 3 ]; then
i=$(( i++ ))
continue
fi
echo "file1 is $file1" # expected $file1 is: scriptName1.sh scriptName2.sh
echo $file1 >> ScriptList.txt # save the two file names in the text file
file1=""
done