sed edit file in place

前端 未结 13 2064
忘掉有多难
忘掉有多难 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条回答
  •  猫巷女王i
    2020-11-22 06:00

    The -i option streams the edited content into a new file and then renames it behind the scenes, anyway.

    Example:

    sed -i 's/STRING_TO_REPLACE/STRING_TO_REPLACE_IT/g' filename
    

    and

    sed -i '' 's/STRING_TO_REPLACE/STRING_TO_REPLACE_IT/g' filename
    

    on macOS.

提交回复
热议问题