As a intermediate step I want to produce one line per string in '' with below script
#!/usr/bin/env/ bash
TOMCAT_OFF=('16:00 19.01.2023' '16:00 21.02.2023' '16:00 15.02.2023')
for i in ${TOMCAT_OFF[@]}
do
echo "${i}"
done
I am getting one line for time + one line for date though (so total 6 instead of 3). I tried various delimiters ('', "", ``) as well as throwing in an escape \ prior the devisive space (like '16:00\ 01.01.2023'
).
Nothing worked thus far though. How can I have bash to interpret a string with spaces as one entity of that list?
"${TOMCAT_OFF[@]}"
, with the quotes to prevent wordsplitting and globbing, and to get the array elements intact. (The quotes don't tie all the values together here, arrays with[@]
are an exception.) Don't put quotes inside your data, they're syntax elements, and trying to mix those with data is almost always a mistake. – ilkkachu Dec 27 '22 at 17:37for i in "${TOMCAT_OFF[@]}"
to be precise (you left the$
out) – vrms Dec 27 '22 at 17:40