Một mục hướng lập trình viên trong kho dữ liệu GitHub của TopGit: chmln/sd, 7.4k sao, nhóm Developer Tools, Rust. Intuitive find & replace CLI (sed alternative)
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
Painless regular expressions.sd uses regex syntax that you already know from JavaScript and Python. Forget about dealing with quirks of sed or awk - get productive immediately.
String-literal mode. Non-regex find & replace. No more backslashes or remembering which characters are special and need to be escaped.
Easy to read, easy to write. 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. Defaults follow common sense and are tailored for typical daily use.
Comparison to sed
While sed does a whole lot more, sd focuses on doing just one thing and doing it well. Here are some cherry-picked examples where sd shines.
Simpler syntax for replacing all occurrences:
sd: sd before after
sed: sed s/before/after/g
Replace newlines with commas:
sd: sd -A '\n' ','
sed: sed ':a;N;$!ba;s/\n/,/g'
Note: this requires -A (across mode) since \n is a cross-line pattern.
Extracting stuff out of strings containing slashes:
sd: echo "sample with /path/" | sd '.*(/.*/)' '$1'
sed: echo "sample with /path/" | sed -E 's/.*(\\/.*\\/)/\1/g'
With sed, you can make it better with a different delimiter,
but it is still messy:
echo "sample with /path/" | sed -E 's|.*(/.*/)|\1|g'
In place modification of files:
sd: sd before after file.txt
sed: sed -i -e 's/before/after/g' file.txt
With sed, you need to remember to use -e or else some
platforms will consider the next argument to be a backup suffix.
sd will interpret every argument starting with - as a (potentially unknown) flag.
The common convention of using -- to signal the end of flags is respected:
$ echo "./hello foo" | sd "foo" "-w"
error: Found argument '-w' which wasn't expected, or isn't valid in this context
USAGE:
sd [OPTIONS] <find> <replace-with> [files]...
For more information try --help
$ echo "./hello foo" | sd "foo" -- "-w"
./hello -w
$ echo "./hello --foo" | sd -- "--foo" "-w"
./hello -w
Processing modes
By default, sd processes input line by line. This means:
Low memory usage (only one line in memory at a time)
Streaming output for stdin (results appear before EOF)
^ and $ match the start/end of each line without phantom matches
\s+$ trims trailing whitespace without eating newlines
If you need patterns to match across line boundaries (e.g. replacing \n or matching multi-line patterns), use the -A / --across flag:
> echo -e "hello\nworld" | sd -A '\n' ','
hello,world
chmln/sd có 7.4k sao GitHub — tải lại trang để xem số mới nhất, hoặc xem trực tiếp github.com/chmln/sd. TopGit phản chiếu số sao của GitHub nhưng không cam kết đến từng phút.
chmln/sd có những chủ đề gì?
GitHub topics của chmln/sd: "cli", "command-line", "regex", "rust", "terminal", "text-processing". TopGit xếp repo vào nhóm Developer Tools.
chmln/sd còn đang phát triển không?
Commit gần nhất trên chmln/sd là 8 tháng trước (theo timestamp GitHub). Repo có 176 fork — một chỉ báo về mức độ quan tâm của cộng đồng.
chmln/sd là gì?
chmln/sd (chmln/sd) là dự án Rust trên GitHub. Theo mô tả gốc: Intuitive find & replace CLI (sed alternative)
chmln/sd so với các dự án Developer Tools khác thế nào?
chmln/sd được TopGit xếp vào nhóm Developer Tools, với 7.4k sao GitHub và viết bằng Rust. Xem trang chủ đề Developer Tools trên TopGit để so sánh với các dự án tương tự theo số sao và mức độ hoạt động.
chmln/sd viết bằng ngôn ngữ gì?
chmln/sd chủ yếu viết bằng Rust. Trường "language" của GitHub dựa trên phần lớn byte ở nhánh mặc định.
Vì sao chmln/sd được xếp vào nhóm Developer Tools?
TopGit xếp chmln/sd vào nhóm Developer Tools dựa trên GitHub topics và mô tả của repo (gắn thẻ: "cli", "command-line", "regex"). Việc phân loại dựa trên metadata thật của repo, không phải đoán theo cảm tính biên tập.
Đọc đầy đủ README ở tab phía trên.
Muốn nghe thêm một ý kiến về sd?
Hỏi một AI đọc được trang này — một cú bấm là có ngay nhận định về sd.