I written shell script to get names of all the files that start with a certain name, as well as all the files that have been edited within the previous day. These file names should be assigned to a single variable. I'm running below script on SUSE Linux 15.
DESTINATIONS="main_crontab"
#get all cron files
find . -name "sample_file_*" -type f -mtime -30 -print0 | while read -d $'\0' file
do
DESTINATIONS+=" ${file}"
done
echo ${DESTINATIONS}
Directory Structure:
Folder_A > sample_file_xx.text (modified today)
Folder_A > sample_file_yy.text (modified today)
Folder_A > sample_file_xx.text (modified two days before)
Expected Output:
echo ${DESTINATIONS} # sample_file_xx.text sample_file_yy.text
Current Output:
echo ${DESTINATIONS} # sample_file_xx.text
sample_file_xx.text
inDESTINATIONS
? I'd expectDESTINATIONS
to contain justmain_crontab
. Can you try again in a fresh shell? Also I just noticed you're running SUSE, which technically makes the question off-topic for this site. That being said I don't think in this specific case it'd make a difference,