#!/bin/sh
arr=(
a
b
c
)
sed "s/abc/${arr[@]}/" file
sh -x this_script.sh shows the result with an error:
+ arr=(a b c)
+ sed s/abc/a b c/ file
sed: -e expression
it should be:
+ sed 's/abc/a b c/' file
this script already has a double quote, why you need to declare a variable for it to work:
x=${arr[@]}
sed "s/abc/$x/" file
source
share