Bash command as variable

前端 未结 5 1095
一个人的身影
一个人的身影 2021-01-24 02:43

I am trying to store the start of a sed command inside a variable like this:

sedcmd=\"sed -i \'\' \"

Later I then execute a command like so:

5条回答
  •  萌比男神i
    2021-01-24 03:33

    Define a shell function:

    mysed () {
        sed -i "" "$@"
    }
    

    and call it like this:

    $ mysed s/$orig_pkg/$package_name/g $f
    

提交回复
热议问题