using sed to find and replace in bash for loop

前端 未结 4 1976
一生所求
一生所求 2021-01-06 15:21

I have a large number of words in a text file to replace.

This script is working up until the sed command where I get:

sed: 1: \"*.js\": inval

4条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-06 15:40

    This looks like a simple typo:

    sed -i "s/{$list[0]}/{$list[1]}/g" *.js
    

    Should be:

    sed -i "s/${list[0]}/${list[1]}/g" *.js
    

    (just like the echo lines above)

提交回复
热议问题