Array elements in sed operation
23:02 06 Nov 2025

I am trying to replace elements on an array using a sed command to compare values between two arrays and replace them accordingly, with the following terminal input:

#!/bin/bash

icons=("" "󰈹" "" "" "") #NerdFont icons
classes=("kitty" "firefox" "discord" "steam" "inkscape")

windowClasses=(kitty kitty kitty kitty steam firefox kitty)

echo $(echo $windowClasses | sed "s/${classes[@]}/${icons[@]}/g")

This, however, outputs the following error:

sed: -e expression #1, char 7: unterminated `s' command

I noticed that if I replace the @ symbol for a number as the array selector the code works as expected, but only replaces the elements in the array with the respective elements in the other arrays (kitty becomes  but firefox doesn't change, for instance) .

bash sed