Update README

This commit is contained in:
Greg 2018-12-30 00:04:38 -05:00
parent 0b6764fe08
commit 636cf2b671

View file

@ -18,6 +18,14 @@ Non-regex find & replace. No more backslashes or remembering which characters ar
Find & replace expressions are split up, which makes them easy to read and write. No more messing with unclosed and escaped slashes.
**Smart, common-sense defaults**
Smart-cased regular expressions also come with a sane syntax that's not opt-in. Defaults follow common sense and are tailored for typical daily use.
**High performance**
Multiple times faster than `sed` beyond trivial cases. (Benchmarks incoming).
## Comparison to sed
While sed does a whole lot more, `sd` focuses on doing just one thing and doing it well.
@ -29,19 +37,15 @@ Some cherry-picked examples, where `sd` shines:
- sed: `sed s/before/after/g`
- Replace newlines with commas:
- sd: `sd '\r' ','`
- sed: `sed ':a;N;$!ba;s/\r/,/g'`, or use a different tool like `tr`.
- Familiar regex syntax by default:
- sd: `echo "start middle end" | sd 'start (.+) end' '$1'`
- sed: basic REs have an unfamiliar and limited syntax, `-E` for more familiar syntax of extended regular expressions is widely supported but not available on some platforms like Solaris:
- `echo "start middle end" | sed 's/start \(..*\) end/\1/g'`
- `echo "start middle end" | sed -E 's/start (.+) end/\1/g'`
- sed: `sed ':a;N;$!ba;s/\r/,/g'`
- Extracting stuff out of strings containing slashes:
- sd: `echo "sample with /path/" | sd '.*(/.*/)' '$1'`
- sed: you need to know that the delimiters for `s` can be replaced with other arbitrary characters
- sed: use different delimiters every time depending on expression so that the command is not completely unreadable
- `echo "sample with /path/" | sed -E 's/.*(/.*/)/\1/g'`
- `echo "sample with /path/" | sed -E 's|.*(/.*/)|\1|g'`
- In place modification of files:
- sd: `sd before after -i file.txt`
- sed: you need to be careful to use `-e` or else some platforms will consider the next argument to be a backup suffix
- sd: `sd -i before after file.txt`
- sed: you need to remember to use `-e` or else some platforms will consider the next argument to be a backup suffix
- `sed -i -e 's/before/after/g' file.txt`
## Installation
@ -52,9 +56,9 @@ Some cherry-picked examples, where `sd` shines:
cargo install sd
```
### OS Packages
### Arch Linux
* **Arch linux:** There's an [AUR package for sd](https://aur.archlinux.org/packages/sd/).
[AUR package for sd](https://aur.archlinux.org/packages/sd/).
## Quick Guide