I use the following sed
command to replace text in the file:
sed -i -e 's/noreply@\(.*\).example.com/[email protected]/' cron.yaml
But it create backup of the file cron.yaml
under name cron.yaml-e
.
I tried to move -i
to the end:
sed -e 's/noreply@\(.*\).example.com/[email protected]/' -i cron.yaml
but in this case sed
returns an error.
How should I modify my command line to avoid backup file creation?
According to the man page you should specify a zero length extension on macOS
sed -i '' -e 's/noreply@\(.*\).example.com/[email protected]/'
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With