Issue
files=("Benjamin Johnson" "Bastin Johnson" "Bagio Johnson")
( IFS=','; echo "${files[*]/#/Mr.}"; echo "${files[*]/ /_}" )
Expected Result
Mr.Benjamin_Johnson,Mr.Bastin_Johnson,Mr.Bagio_Johnson
Output result:
Mr.Benjamin Johnson,Mr.Bagio Johnson,Mr.Bastin Johnson
Benjamin_Johnson,Bagio_Johnson,Bastin_Johnson
Solution
Just use an intermediate array.
( IFS=','; files=("${files[@]/#/Mr.}"); echo "${files[*]/ /_}" )
Answered By - KamilCuk Answer Checked By - Katrina (WPSolving Volunteer)