Using SED to replace a line with spaces
-
I'm trying to replace a line in a file using sed.
so
sed -i 's~Your sentence that needs to be replaced~New sentence goes here~g' /file/path/file
Should work, right? It doesn't result in an error when running my command, but the file doesn't get changed.
Looking for guidance.
-
Paging @travisdh1 @scottalanmiller @JaredBusch
One of you three should know how to do this.
-
That looks good to me and works fine here.
Only thing that comes to mind is the file permissions?
-
@bnrstnr Okay, will try it again. And I'm running this as root, so not sure.
-
I typically use
/
instead of~
for the delimiter, looks right. -
@JaredBusch said in Using SED to replace a line with spaces:
I typically use
/
instead of~
for the delimiter, looks right.Have to use ~ because I'm adding a URL in the part that's being replaced.
Also that did work, not sure why it wasn't showing the change first time.
Thanks for the sanity check.
-
@DustinB3403 said in Using SED to replace a line with spaces:
@JaredBusch said in Using SED to replace a line with spaces:
I typically use
/
instead of~
for the delimiter, looks right.Have to use ~ because I'm adding a URL in the part that's being replaced.
Also that did work, not sure why it wasn't showing the change first time.
Thanks for the sanity check.
wait...... I skimmed. I admit..
You have to escape spaces or wrap it in quotes.
Oh it worked.. then all good. Ignore me..
I'm busy unpurging email.