TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Show HN: Hck – a fast and flexible cut-like tool

151 点作者 totalperspectiv将近 4 年前

10 条评论

lillesvin将近 4 年前
I wrote something similar (but necet really finished it), called &#x27;gut&#x27;, in Go a few years back. Funny thing is, that I literally never use it. I thought splitting on regexes and that stuff would be super useful, but it turns out that I just use Perl one-liners instead. And Perl is available on something like 99.99% of all *nix machines, which my own &#x27;cut&#x27;-substitute isn&#x27;t.<p>Still a good exercise for me to write it, and I assume for OP too.
评论 #27795553 未加载
评论 #27795508 未加载
评论 #27796094 未加载
评论 #27795465 未加载
rashil2000将近 4 年前
Love seeing these modern alternatives to coreutils! Ripgrep, fd, hyperfine, bat, exa, bottom, gdu, wc, sd, hexyl...<p>Yet to find a GNU &#x27;tr&#x27; alternative though
评论 #27798212 未加载
评论 #27796799 未加载
评论 #27814342 未加载
评论 #27796748 未加载
评论 #27795155 未加载
kitd将近 4 年前
Nice work!<p>I don&#x27;t know whether anyone here has used Rexx. The &#x27;parse&#x27; instruction in Rexx was incredibly powerful, breaking up text by field&#x2F;position&#x2F;delimiter and assigning to variables all in one line.<p>I&#x27;ve often wondered if there was a command-line equivalent. Awk is great but you have to &#x27;program&#x27; the parsing spec, rather than declare it.
评论 #27796167 未加载
评论 #27796884 未加载
bilalhusain将近 4 年前
It is interesting to note how it compares to &quot;choose&quot; (also in Rust) in the benchmarks.<p>single character<p><pre><code> hck 1.494 ± 0.026s hck (no-mmap) 1.735 ± 0.004s choose 4.597 ± 0.016s </code></pre> multi character<p><pre><code> hck 2.127 ± 0.004s hck (no-mmap) 2.467 ± 0.012s choose 3.266 ± 0.011s </code></pre> The single pass optimization trick[1] seems to be helping a lot in single character case.<p>Of course, doing away with a pass is suppossed to give 2x, and I am wondering whether the regex constraint lead to this &quot;side-effect&quot;.<p>[1] fast mode - <a href="https:&#x2F;&#x2F;github.com&#x2F;sstadick&#x2F;hck&#x2F;blob&#x2F;master&#x2F;src&#x2F;lib&#x2F;core.rs#L194" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;sstadick&#x2F;hck&#x2F;blob&#x2F;master&#x2F;src&#x2F;lib&#x2F;core.rs#...</a> <a href="https:&#x2F;&#x2F;github.com&#x2F;sstadick&#x2F;hck&#x2F;blob&#x2F;master&#x2F;src&#x2F;lib&#x2F;core.rs#L324-L331" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;sstadick&#x2F;hck&#x2F;blob&#x2F;master&#x2F;src&#x2F;lib&#x2F;core.rs#...</a>
asicsp将近 4 年前
I saw about `hck` recently on twitter, was impressed to see support for compressed files. From the current todo list, I hope complement is implemented for sure.<p>I see Negative index is currently &quot;unlikely&quot;. I&#x27;m writing a similar tool [0], but with bash+awk. I solved the negative index support with a `-n` option, which changes the range syntax to `:` instead of `-` character.<p>My biggest trouble came with literal field separator [1], because FS can only be specified as a string in awk and backslash is a metacharacter for both string and regexp.<p>[0] <a href="https:&#x2F;&#x2F;github.com&#x2F;learnbyexample&#x2F;regexp-cut" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;learnbyexample&#x2F;regexp-cut</a><p>[1] <a href="https:&#x2F;&#x2F;learnbyexample.github.io&#x2F;escaping-madness-awk-literal-field-separator&#x2F;" rel="nofollow">https:&#x2F;&#x2F;learnbyexample.github.io&#x2F;escaping-madness-awk-litera...</a>
visarga将近 4 年前
&lt;offtopic&gt; I have implemented a `_split` command to split a line by a separator and `_stat` command that does basically `sort | uniq -c | sort -nr` counting elements and sorting by frequency. Really useful operations for me.<p>When my one liners become 2-3 lines long I need to switch to a regular script, but I also log all my shell commands years back and have something a bit better than `history | grep word` to search it.&lt;&#x2F;&gt;
评论 #27800309 未加载
rendall将近 4 年前
The README and description should not assume the reader knows what `cut` is or what it&#x27;s used for. Maybe reference it and then ELI5
technological将近 4 年前
Nice one op. It’s mostly due to my lack of knowledge of rust but the code is not easy to read unlike golang. Does anyone feel the same ? (between nothing to do with how op wrote but rather the language itself)
评论 #27797993 未加载
queuebert将近 4 年前
Yay, no more piping multiple cuts when you have multiple delimiters.
toastal将近 4 年前
Heck
评论 #27794839 未加载