I am trying to iterate over an array of file names and substitute the file name inside an absolute path. The code is,
#!/bin/bash
jsArray=(moment.js datatable.js jquery.js jquery.tmpl.js dt_jq_ui.js report_app.js)
for f in "/path/to/res/${jsArray[@]}.js";
do
echo "$f"
done
It returns,
/path/to/res/moment.js
datatable.js
jquery.js
jquery.tmpl.js
dt_jq_ui.js
report_app.js.js
Why does only the first element get prefixed, and only the last element get suffixed?
I expected entries like,
/path/to/res/moment.js
/path/to/res/datatable.js
..................
/path/to/res/report_app.js