In a bash script I would like to loop on an array and execute a sed command each times. Basically, I would like to do something like that :
names=( "Peter" "Juan Carlos" "Emily")
for name in ${names[*]}
do
sed 's/[[:space:]]*{'"$name"'}/'"$name"'/g' "$file"
done
What do I miss ?
EDIT : I explain further my intention:
My source is a tex document with lines like :
\begin{cue}
{Peter}
{You won !}
\end{cue}
\begin{cue}
{Juan Carlos}
{Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc vitae ipsum hendrerit, gravida est eget, tincidunt sem. Maecenas dapibus nibh commodo, pulvinar lorem at, egestas leo.}
\end{cue}
In fine, I'd like to have a .csv document formated like
"Peter";"You won! "Juan Carlos";"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc vitae ipsum hendrerit, gravida est eget, tincidunt sem. Maecenas dapibus nibh commodo, pulvinar lorem at, egestas leo."
Thanks for your answers !
sed "s/[[:space:]]*{'\"$name\"'}/... you get the idea.sed 's/[[:space:]]*\(Peter\|Juan Carlos\|Emily\)/\1/g' "$file"will do this without a loop or duplicate output.