sed edit file in place

前端 未结 13 1709
忘掉有多难
忘掉有多难 2020-11-22 05:20

I am trying to find out if it is possible to edit a file in a single sed command without manually streaming the edited content into a new file and

13条回答
  •  礼貌的吻别
    2020-11-22 06:05

    Very good examples. I had the challenge to edit in place many files and the -i option seems to be the only reasonable solution using it within the find command. Here the script to add "version:" in front of the first line of each file:

    find . -name pkg.json -print -exec sed -i '.bak' '1 s/^/version /' {} \;
    

提交回复
热议问题