Substitution with sed + bash function

后端 未结 7 2091
一向
一向 2021-01-03 02:26

my question seems to be general, but i can\'t find any answers.

In sed command, how can you replace the substitution pattern by a value returned by a simple bash fun

7条回答
  •  旧巷少年郎
    2021-01-03 02:44

    you can use the "e" option in sed command like this:

    cat t.sh
    
    myecho() {
            echo ">>hello,$1<<"
    }
    export -f myecho
    sed -e "s/.*/myecho &/e" <

    you can see the result without "e":

    cat t.sh
    
    myecho() {
            echo ">>hello,$1<<"
    }
    export -f myecho
    sed -e "s/.*/myecho &/" <

提交回复
热议问题