I do not know if this topic was reached or not bot couldn't find anything related.
I have a bash script and I want to do a for loop through multiple directories with the mention that I want to output in a log file only *.txt/files but the loop to don't go on sub-directories.
My desire is to use the directories in variables. I am using an array where I wrote the directories I search for them. When the script is ran the output is what is in array, not what is in the directories...
This is how my code look now, what should I do?:
#!/bin/bash
l=/home/Files/Test1/
j=/home/Files/Test2/
k=/home/Files/Test3/
arr=("$l" "$j" "$k")
for i in "${arr[*]}"
do
echo "$i" >> test
done
Thank you for any help!
I want to do a for loop through multiple directoriesYou say that, yet I think you meant that you want to loop through files in multiple directories, not through directories.