-
Notifications
You must be signed in to change notification settings - Fork 140
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
Is this possible? #285
Comments
Side note: you can surround any lines of code or otherwise preformatted content with a pair of And yes, you can do that:
This is kinda awkward if you are used to sed syntax, but otherwise just plain old regular expression. |
This is not what I want to achieve. |
I don't quite follow. |
The result I want to get is |
Alright, I misunderstood ("over-interpreted" if you would) the single line example to be multiple lines misrepresented, due to the words "all lines". As I now understand it, you want the replacement to happen iff a predicate is true. This as a general case is not possible with plain regexes (how sd currently operates). In a plain regex, after the "predicate" This is trivially solved with a little scripting if you are open to that. If deemed necessary for sd, this probably needs a semantics along the lines of I'd suggest changing the title to something like "Predicated replacements". |
I have a line
line=Note AAA: BBB: CCC:
I want to replace the ':' in all lines starting with Note with the character Z
This would make the 'sd : Z' conditional on the presence of 'Note'
Is this possible with sd ?
In sed, i would do"
sed '/^Note/s/:/Z/g' myfile
Many thanks
The text was updated successfully, but these errors were encountered: