How to globally replace strings in lines NOT starting with a certain pattern

前端 未结 3 1867
庸人自扰
庸人自扰 2020-12-23 17:13

I want to globally replace the string foo with the string bar, using sed. This should only be done for lines which do NOT start with the string ##Input.

I can\'t get

3条回答
  •  生来不讨喜
    2020-12-23 17:53

    An ugly answer for an ugly request (i.e. they get what they asked for):

    echo \{
    for file in *.json; do
        sed -n '/^[\{\}]/! s/\([^\,]\)$/\1,/; /^[\{\}]/!p' $file
    done
    echo \{
    

提交回复
热议问题