[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-5585":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":17,"stars7d":18,"stars30d":19,"stars90d":16,"forks30d":16,"starsTrendScore":20,"compositeScore":21,"rankGlobal":10,"rankLanguage":10,"license":22,"archived":23,"fork":23,"defaultBranch":24,"hasWiki":23,"hasPages":23,"topics":25,"createdAt":10,"pushedAt":10,"updatedAt":32,"readmeContent":33,"aiSummary":34,"trendingCount":16,"starSnapshotCount":16,"syncStatus":35,"lastSyncTime":36,"discoverSource":37},5585,"sd","chmln\u002Fsd","chmln","Intuitive find & replace CLI (sed alternative)","",null,"Rust",7186,160,32,57,0,1,15,79,7,37.62,"MIT License",false,"master",[26,27,28,29,30,31],"cli","command-line","regex","rust","terminal","text-processing","2026-06-12 02:01:12","# sd - `s`earch & `d`isplace\n\n`sd` is an intuitive find & replace CLI.\n\n## The Pitch\n\nWhy use it over any existing tools?\n\n*Painless regular expressions.* &nbsp; `sd` uses regex syntax that you already know from JavaScript and Python. Forget about dealing with quirks of `sed` or `awk` - get productive immediately.\n\n*String-literal mode.* &nbsp; Non-regex find & replace. No more backslashes or remembering which characters are special and need to be escaped.\n\n*Easy to read, easy to write.* &nbsp; Find & replace expressions are split up, which makes them easy to read and write. No more messing with unclosed and escaped slashes.\n\n*Smart, common-sense defaults.* &nbsp; Defaults follow common sense and are tailored for typical daily use.\n\n## Comparison to sed\n\nWhile 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.\n\nSimpler syntax for replacing all occurrences:\n  - sd: `sd before after`\n  - sed: `sed s\u002Fbefore\u002Fafter\u002Fg`\n\nReplace newlines with commas:\n  - sd: `sd -A '\\n' ','`\n  - sed: `sed ':a;N;$!ba;s\u002F\\n\u002F,\u002Fg'`\n\n  Note: this requires `-A` (across mode) since `\\n` is a cross-line pattern.\n\nExtracting stuff out of strings containing slashes:\n  - sd: `echo \"sample with \u002Fpath\u002F\" | sd '.*(\u002F.*\u002F)' '$1'`\n  - sed: `echo \"sample with \u002Fpath\u002F\" | sed -E 's\u002F.*(\\\\\u002F.*\\\\\u002F)\u002F\\1\u002Fg'`\n    \n    With sed, you can make it better with a different delimiter,\n    but it is still messy:\n    \n    `echo \"sample with \u002Fpath\u002F\" | sed -E 's|.*(\u002F.*\u002F)|\\1|g'`\n\nIn place modification of files:\n  - sd: `sd before after file.txt`\n  - sed: `sed -i -e 's\u002Fbefore\u002Fafter\u002Fg' file.txt`\n    \n    With sed, you need to remember to use `-e` or else some\n    platforms will consider the next argument to be a backup suffix.\n\n## Benchmarks\n\n**Simple replacement on ~1.5 gigabytes of JSON**\n\n```sh\nhyperfine --warmup 3 --export-markdown out.md \\\n  'sed -E \"s\u002F\\\"\u002F'\"'\"'\u002Fg\" *.json > \u002Fdev\u002Fnull' \\\n  'sed    \"s\u002F\\\"\u002F'\"'\"'\u002Fg\" *.json > \u002Fdev\u002Fnull' \\\n  'sd     \"\\\"\" \"'\"'\"'\"   *.json > \u002Fdev\u002Fnull'\n```\n\n| Command | Mean [s] | Min…Max [s] |\n|:---|---:|---:|\n| `sed -E \"s\u002F\\\"\u002F'\u002Fg\" *.json > \u002Fdev\u002Fnull` | 2.338 ± 0.008 | 2.332…2.358 |\n| `sed    \"s\u002F\\\"\u002F'\u002Fg\" *.json > \u002Fdev\u002Fnull` | 2.365 ± 0.009 | 2.351…2.378 |\n| `sd     \"\\\"\" \"'\"   *.json > \u002Fdev\u002Fnull` | **0.997 ± 0.006** | 0.987…1.007 |\n\nResult: ~2.35 times faster\n\n**Regex replacement on a ~55M json file**:\n\n```sh\nhyperfine --warmup 3 --export-markdown out.md \\\n  'sed -E \"s:(\\w+):\\1\\1:g\"    dump.json > \u002Fdev\u002Fnull' \\\n  'sed    \"s:\\(\\w\\+\\):\\1\\1:g\" dump.json > \u002Fdev\u002Fnull' \\\n  'sd     \"(\\w+)\" \"$1$1\"      dump.json > \u002Fdev\u002Fnull'\n```\n\n| Command | Mean [s] | Min…Max [s] |\n|:---|---:|---:|\n| `sed -E \"s:(\\w+):\\1\\1:g\"    dump.json > \u002Fdev\u002Fnull` | 11.315 ± 0.215 | 11.102…11.725 |\n| `sed    \"s:\\(\\w\\+\\):\\1\\1:g\" dump.json > \u002Fdev\u002Fnull` | 11.239 ± 0.208 | 11.057…11.762 |\n| `sd     \"(\\w+)\" \"$1$1\"      dump.json > \u002Fdev\u002Fnull` | **0.942 ± 0.004** | 0.936…0.951 |\n\nResult: ~11.93 times faster\n\n**Line-by-line vs across mode** (1M lines, ~36MB file):\n\n| Command | Mean [ms] | Relative |\n|:---|---:|---:|\n| `sd -A 'foo' 'qux'` (across) | 125.6 ± 14.3 | 1.00 |\n| `sed s\u002Ffoo\u002Fqux\u002Fg` | 316.4 ± 30.0 | 2.52 |\n| `sd 'foo' 'qux'` (line-by-line, default) | 357.0 ± 15.0 | 2.84 |\n\n| Command | Mean [ms] | Relative |\n|:---|---:|---:|\n| `sd -A '(\\w+) world' '$1 earth'` (across) | 254.0 ± 11.2 | 1.00 |\n| `sd '(\\w+) world' '$1 earth'` (line-by-line, default) | 566.7 ± 16.7 | 2.23 |\n| `sed -E 's\u002F(\\w+) world\u002F\\1 earth\u002Fg'` | 4432.7 ± 173.2 | 17.45 |\n\nLine-by-line mode is ~2-3x slower than across mode but still faster than sed for regex replacements. The tradeoff is dramatically lower memory usage:\n\n| Mode | Peak RSS |\n|:---|---:|\n| `sd -A` (across) | 74 MB |\n| `sd` (line-by-line, default) | 3 MB |\n\n## Installation\n\nInstall through\n[`cargo`](https:\u002F\u002Fdoc.rust-lang.org\u002Fcargo\u002Fgetting-started\u002Finstallation.html) with\n`cargo install sd`, or through various package managers\n\n[![Packaging status](https:\u002F\u002Frepology.org\u002Fbadge\u002Fvertical-allrepos\u002Fsd-find-replace.svg?exclude_unsupported=1)](https:\u002F\u002Frepology.org\u002Fproject\u002Fsd-find-replace\u002Fversions)\n\n## Quick Guide\n\n1. **String-literal mode**. By default, expressions are treated as regex. Use `-F` or `--fixed-strings` to disable regex.\n\n   ```sh\n   > echo 'lots((([]))) of special chars' | sd -F '((([])))' ''\n   lots of special chars\n   ```\n\n2. **Basic regex use** - let's trim some trailing whitespace\n\n   ```sh\n   > echo 'lorem ipsum 23   ' | sd '\\s+$' ''\n   lorem ipsum 23\n   ```\n\n3. **Capture groups**\n\n   Indexed capture groups:\n\n   ```sh\n   > echo 'cargo +nightly watch' | sd '(\\w+)\\s+\\+(\\w+)\\s+(\\w+)' 'cmd: $1, channel: $2, subcmd: $3'\n   cmd: cargo, channel: nightly, subcmd: watch\n   ```\n\n   Named capture groups:\n\n   ```sh\n   > echo \"123.45\" | sd '(?P\u003Cdollars>\\d+)\\.(?P\u003Ccents>\\d+)' '$dollars dollars and $cents cents'\n   123 dollars and 45 cents\n   ```\n\n   In the unlikely case you stumble upon ambiguities, resolve them by using `${var}` instead of `$var`. Here's an example:\n\n   ```sh\n   > echo '123.45' | sd '(?P\u003Cdollars>\\d+)\\.(?P\u003Ccents>\\d+)' '$dollars_dollars and $cents_cents'\n    and\n\n   > echo '123.45' | sd '(?P\u003Cdollars>\\d+)\\.(?P\u003Ccents>\\d+)' '${dollars}_dollars and ${cents}_cents'\n   123_dollars and 45_cents\n   ```\n\n4. **Find & replace in a file**\n\n   ```sh\n   > sd 'window.fetch' 'fetch' http.js\n   ```\n\n   That's it. The file is modified in-place.\n\n   To preview changes:\n\n   ```sh\n   > sd -p 'window.fetch' 'fetch' http.js\n   ```\n\n5. **Find & replace across project**\n\n   This example uses [fd](https:\u002F\u002Fgithub.com\u002Fsharkdp\u002Ffd).\n\n   Good ol' unix philosophy to the rescue.\n\n   ```sh\n   fd --type file --exec sd 'from \"react\"' 'from \"preact\"'\n   ```\n\n   Same, but with backups (consider version control).\n\n   ```bash\n   fd --type file --exec cp {} {}.bk \\; --exec sd 'from \"react\"' 'from \"preact\"'\n   ```\n\n### Edge cases\nsd will interpret every argument starting with `-` as a (potentially unknown) flag.\nThe common convention of using `--` to signal the end of flags is respected:\n\n```bash\n$ echo \".\u002Fhello foo\" | sd \"foo\" \"-w\"\nerror: Found argument '-w' which wasn't expected, or isn't valid in this context\n\nUSAGE:\n    sd [OPTIONS] \u003Cfind> \u003Creplace-with> [files]...\n\nFor more information try --help\n$ echo \".\u002Fhello foo\" | sd \"foo\" -- \"-w\"\n.\u002Fhello -w\n$ echo \".\u002Fhello --foo\" | sd -- \"--foo\" \"-w\"\n.\u002Fhello -w\n```\n\n### Processing modes\n\nBy default, sd processes input **line by line**. This means:\n- Low memory usage (only one line in memory at a time)\n- Streaming output for stdin (results appear before EOF)\n- `^` and `$` match the start\u002Fend of each line without phantom matches\n- `\\s+$` trims trailing whitespace without eating newlines\n\nIf you need patterns to match **across line boundaries** (e.g. replacing `\\n` or matching multi-line patterns), use the `-A` \u002F `--across` flag:\n\n```sh\n> echo -e \"hello\\nworld\" | sd -A '\\n' ','\nhello,world\n```\n\n### Escaping special characters\nTo escape the `$` character, use `$$`:\n\n```bash\n❯ echo \"foo\" | sd 'foo' '$$bar'\n$bar\n```\n","sd 是一个直观的查找与替换命令行工具，旨在替代传统的 sed 工具。它使用类似于 JavaScript 和 Python 的正则表达式语法，使得用户无需记忆 sed 或 awk 的特殊规则即可快速上手。sd 支持非正则表达式的字符串字面量模式，简化了转义字符的处理；同时通过将查找和替换表达式分开来提高可读性和编写效率，并且提供了符合直觉的默认设置。该项目特别适合需要频繁进行文本处理但又希望避免复杂命令配置的开发者或系统管理员使用。",2,"2026-06-11 03:04:13","top_language"]