read -r -p "Enter the filenames: " -a arr
for filenames in "${arr[@]}"; do
if [[ -e "${filenames}" ]]; then
echo "${filenames} file exists (no override)"
else
cp -n ~/Documents/library/normal.py "${filenames}"
fi
done
Suppose, I've B.py D.py in a folder.
When I run this script in the same folder and write A.py B.py C.py D.py (undefined number of inputs)
Files named A.py C.py are copied successfully.
Whereas for B.py D.py, it shows B.py file exists (no override) and D.py file exists (not override) respectively.
I want to store elements which did worked and which didn't work in separate arrays from main array ${arr[@]}
arr=('A.py' 'B.py' 'C.py' 'D.py')
didworked=('A.py' 'C.py')
notworked=('B.py' 'D.py')
How can i do that? Any suggestions, please.