banderas20
Active Member
Hi,
I'm developing a shellscript which searches through an specific directory and stores filenames in 3 arrays (files1, files2 and files3).
I have 3 dates to search through (date1, date2, and date3)
Then I append the 3 arrays in a single one as follows:
However, when I iterate through "filesTotal", I get something like this:
That is,
I was expecting something like this:
I mean, empty value removed and all the names formatted in a single column.
¿can you help me out?
Thanks!
I'm developing a shellscript which searches through an specific directory and stores filenames in 3 arrays (files1, files2 and files3).
I have 3 dates to search through (date1, date2, and date3)
Code:
files1=$(ls -1 filename_$date1*.txt 2>/dev/null)
files2=$(ls -1 filename_$date2*.txt 2>/dev/null)
files3=$(ls -1 filename_$date3*.txt 2>/dev/null)
Then I append the 3 arrays in a single one as follows:
Code:
filesTotal=( "${files1[@]}" "${files2[@]}" "${files3[@]}")
However, when I iterate through "filesTotal", I get something like this:
Code:
file1.txt
file2.txt file3.txt
That is,
- A single file with the contents of the first array.
- An empty value, because second array has nothing.
- file2.txt and file3.txt (side by side)
I was expecting something like this:
Code:
file1.txt
file2.txt
file3.txt
I mean, empty value removed and all the names formatted in a single column.
¿can you help me out?
Thanks!