I wrote a bash script that extract only the date from folder names and put what extract (dates) in a array to perform other operations. Local works fine, the problems appears when I want to do this remote on server.
I access the server via ssh , the part that extract the date from folder names work ok the main issue is when I want to populate the array with the dates.
Below are some code from my script:
#! bin/bash
ssh -t -t user@serveradress << 'EOT'
# go in the path where to perform the extraction of dates
cd share/Pictures_G
# create an array, perform the extraction of dates , populate the array with dates
declare -a all_dates
all_dates=($(ls | grep -o "[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}"))
len=${all_dates[@]}
echo "$len"
EOT
So the command ls | grep -o "[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}"
work ok alone but when I use this in the way that I used in the script from above provide the next output:
all_dates=
len=
echo
nothing is passed to the array from my understanding.