Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can you remove a line with sd? #132

Closed
EmilSodergren opened this issue Jun 29, 2021 · 3 comments
Closed

Can you remove a line with sd? #132

EmilSodergren opened this issue Jun 29, 2021 · 3 comments
Labels
M-needs triage Meta: Maintainer label me!

Comments

@EmilSodergren
Copy link

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... 😄

@jorunfa
Copy link

jorunfa commented Jun 30, 2021

Just use \n in your pattern?

sd 'foo\n' ''

@balupton
Copy link

balupton commented Dec 2, 2021

possible dupe of #99

@CosmicHorrorDev CosmicHorrorDev added the M-needs triage Meta: Maintainer label me! label May 17, 2023
@CosmicHorrorDev
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
M-needs triage Meta: Maintainer label me!
Projects
None yet
Development

No branches or pull requests

4 participants