sed command in dry run

后端 未结 3 1392
情深已故
情深已故 2021-02-02 05:51

How it is possible to make a dry run with sed?

I have this command:

find ./ -type f | xargs sed -i \'s/string1/string2/g\'

3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-02 06:36

    I would prefer to use the p-option:

    find ./ -type f | xargs sed 's/string1/string2/gp'
    

    Could be combined with the --quiet parameter for less verbose output:

    find ./ -type f | xargs sed --quiet 's/string1/string2/gp'
    

    From man sed:

    p:

    Print the current pattern space.

    --quiet:

    suppress automatic printing of pattern space

提交回复
热议问题