I noticed a number of similar questions ask and I also tried the suggestions posted, but I just can't seem to get this working. Below is my code.
#!/bin/bash
while IFS="" read -d "" -r filename;
do
filearray[i++]="$filename"
done < <(find . -maxdepth 1 -type f -iname "*.txt" -print0)
printf '%s\n' "${filearray[0]}"
Simply, I just want to search for all txt type files in a specific directory and put them into an array, which is displayed at the end. When I run from the command line, no problem. It works well. As soon as I execute this via crontab, I get the following error:
syntax error near unexpected token `<'
`done < <(find . -maxdepth 1 -type f -iname "*.txt" -print0)'
Here's the cron entry itself:
* * * * * . /usr/online/scripts/test.sh 2>> /usr/online/scripts/log/test.log
Why is the script working on command line, but not crontab? I am declaring the shell, so surely crontab should use the shell? Is there another why I can do this which works?
Jakkie