SED without backup file

前端 未结 2 1365
你的背包
你的背包 2020-12-25 10:23

I use the following sed command to replace text in the file:

sed -i -e \'s/noreply@\\(.*\\).example.com/noreply@example.com/\' cron.yaml
         


        
2条回答
  •  梦毁少年i
    2020-12-25 10:33

    On Windows the GNUWIN32 sed FAILS, when putting any of this:

    sed -i "s/WhatToFind/WhatToPut/g" ".\MyDir\*"

    sed -i.BackUp "s/WhatToFind/WhatToPut/g" ".\MyDir\*"

    The BackUps are allways created on actual folder with a file name pattern of sed$$$$$$, where that six $ represents random leters and numbers.

    I see no way for it to not create any BackUP at all, neither to create BackUPs that can be know to which file was the source, neither create backups on the same folder as source file.

    And it also tries to read sub-folders as is they where files, of courrse showing an impossible to read message for such sub-folders; and of course it does not recurse sub-folders, it only works with all on the same folder, but not with what is on sub-folders (not recursive).

    In shorts words: -i is not working at all as spected.

    GNUWIN32 sed version i am using is 4.2.1, it was downloaded from: http://gnuwin32.sourceforge.net/packages/sed.htm

    On Google i found a web that talks about that BUG and remomends to download a ssed instead to sed tool, i am a little afraid of not being official; link to what i found on Google about that -i BUG on sed: http://www.thinkplexx.com/learn/snippet/cmd/one-liner/working-in-place-sed-option-under-windows

提交回复
热议问题