-
Notifications
You must be signed in to change notification settings - Fork 142
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
Are these features missing or not intended? Possibility in the future? #297
Comments
Hey @emrakyz thanks for taking the time to write this all out.
|
Thanks for your answer! I understand that the actual aim is to use this tool for simple tasks and in fact I already do that. Sometimes, I also use it in scripts for simple tasks since it's faster for simple purposes. It really makes a difference especially since we can get rid of forward slashes and escaping. At first, I was discovering Rust based tools and found that I agree that the features such as append, conditionals, labels or loops that make But I still think that some of the features can still be discussed. I think they won't make the program overly complex for the users since they can already use the current functionality. These are just my observations and I would like to have your opinion; or other people's comments. The features I think that are suitable for this project are:
Thanks a lot for creating this tool and I hope it doesn't die. |
I aimed to replace
sed
withsd
but I guess, this is not the main idea of it.This post is meant for the community. So, maybe some of these features will be requested by a considerable amount of people, so they will be considered to be implemented in the future.
Or, maybe the developers would recommend better alternatives, different ways we don't know about.
I am assuming that
sed
was developed with an aim that it would have been a scripting language on its own. You can write multi-linesed
commands in a single session having conditionals, loops and similar processes. I am not completely sure if some of these are possible onsd
or if you do have any plans to make at least some of these possible.I am assuming that the syntax for
sd
where we split pattern and replacement in two different blocks with quotes, makes most of these impossible or harder. Or not? Please correct me if I am wrong.I think, there would be a lot more similar or non-similar examples where
sd
is lacking. I will only give some examples since I could only encounter some of them trying to use it.First Example
sd
commands. Therefore, it becomes a lot slower.Second Example
It is the same for simpler commands:
sed -E '1d;$d; s/^ *([0-9]+).*\s{2,}(.+)$/\1 \2/'
sd
commands or other commands such ashead
ortail
make it a lot slower and less minimal thansed
.Third Example
The other command also does a match, and then operate on the match to delete 11 next lines after the match.
Fourth Example
sed -e :a -e '/^\n*$/N; /^\n$/D; ta' "logfile.txt"
a
. Labels are used for conditional matching and loops.N;
appends the next line of input to the pattern space (a kind of working buffer).D;
Deletes the first line in the pattern space and starts a new cycle (not processing the remaining commands).t
is the conditional branch command. It tellssed
to jump to a label if a previous substitution was successful.a
is the label where thesed
will jump if the substitution successful.In short, this command removes consecutive blank lines, leaving only a single blank line between blocks of text. First match looks for an empty line. If the second match is also true, then it deletes the first match.
Fifth Example
sed -n '/0\s*c12a7328-f81f-11d2-ba4b-00a0c93ec93b/ {s|^[^ ]*|/dev/&|; s| .*||p; q}'
-n
.lsblk
command in order to find all partitions, filter the EFI partition, append/dev/
prefix on it. Therefore we can find the boot partition successfully with a single command.Sixth Example
sed -i '|^nvidia/'"${GPU_CODE}"'|!d' "linux-firmware-"*
!d
on the Linux Firmware configuration.sd
in a way where we match the lines completely with regex using[^pattern]
and replace the result with nothing.Seventh Example
sed -i /^FFLAGS/ a\RUSTFLAGS="-C debuginfo=0 -C codegen-units=1 -C target-cpu=native -C opt-level=3"'
a\
Append the RUSTFLAGS variable just under the FFLAGS variable.$1\nRUSTFLAGS...
Eighth Example
sed -n 's|^|/dev/|; 2p'
/dev/
prefix and print the second line.The text was updated successfully, but these errors were encountered: