sd
sd copied to clipboard
Can you remove a line with sd?
Is it possible to remove lines with sd? You could of course "replace line with empty" but that leaves unwanted empty blank lines. With sed you write sed -i '/pattern to match/d' ./infile
. Is there something similar in sd? I think that functionality is the only thing that still keeps sed in my toolbox... :smile:
Just use \n
in your pattern?
sd 'foo\n' ''
possible dupe of https://github.com/chmln/sd/issues/99
As @jorunfa mentioned you just need to include the newline in the pattern. If you want to support text that uses \r\n
as well then you can use \r?\n