I'm trying replace a word in a file using sed. In the same bash script I use the command :
sed -i "s/${list[$index]}/${phone}/g" $1 And it's working flawlessly on the first function, but the second function I wrote:
sed -i "s/${list[$index]}/${zipcode}/g" $1 Outputs this error:
sed: -e expression #1, char 0: no previous regular expression I'm really desperate, I'm pretty sure that it's a dumb mistake I'm doing but I can't sort it out
sed -i "s|${list[$index]}|${zipcode}|g" $1). Also try to remove-iswitch for testing and also try to replace$1with the real file. Switch-iwill not work if$1is not a real valid file (avoid also relative paths)printf '%q\n' "${list[$index]}" "${phone}" "${zipcode}"in your question.${list[$index]}is the empty string.