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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Show HN: Bsed – Simple, English syntax on top of Perl text processing

178 点作者 bihla大约 6 年前

17 条评论

peteretep大约 6 年前
Kinda off that this is written in Python, and not Perl. If it was written in Perl, it&#x27;d have the portability that the underlying translated commands have!<p>I&#x27;d be happy to help you port it to modern, high-quality, readable Perl if that&#x27;s something you&#x27;re interested in. Being able to install this by dropping a single Perl file into ~&#x2F;bin&#x2F; would be neat.
评论 #19540886 未加载
评论 #19546708 未加载
评论 #19546758 未加载
评论 #19546712 未加载
ilovetux大约 6 年前
Perl aside, I would say that&#x27;s almost imperative to learn sed and awk. They invaluable tools for getting things done in *nix. They seem cryptic at first, but put a weekend into learning them and you learn that they are simply concise.
评论 #19542137 未加载
评论 #19541833 未加载
disposedtrolley大约 6 年前
This is cool! I’ve wanted to explore something similar but incorporating a broad range of Unix commands.<p>I imagined a drag and drop interface (sort of like the Scratch programming language) with English descriptors of the functions being performed. You’d make it a web UI or something that generates a bash script you can paste into the terminal.
asicsp大约 6 年前
some notes on the sample awk&#x2F;sed&#x2F;perl one-liner given:<p><pre><code> # input line has to be explicitly printed awk &#x27;{gsub(&#x2F;Jack&#x2F;,&quot;Jill&quot;)} 1&#x27; file.txt # -i will do inplace editing, unlike the awk command # -i by itself won&#x27;t work on non-GNU versions, needs backup extension sed &#x27;s&#x2F;Jack&#x2F;Jill&#x2F;g&#x27; file.txt # use single quotes always, unless double is needed # -p will behave like default sed perl -pe &#x27;s&#x2F;Jack&#x2F;Jill&#x2F;g&#x27; file.txt </code></pre> personally, I prefer the terseness of these commands over verbose SQL like syntax (and also the fact that I don&#x27;t know SQL like tools)<p>However, I would agree that initial learning curve is tough for sed&#x2F;awk&#x2F;perl. Once you get familiar with their idioms, they become the swiss army knife of cli text processing (along with grep). I have an entire repo dedicated to such tools[1]<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;learnbyexample&#x2F;Command-line-text-processing" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;learnbyexample&#x2F;Command-line-text-processi...</a>
评论 #19540464 未加载
bihla大约 6 年前
I&#x27;d love to hear any questions or feedback. I&#x27;ve gotten quite a bit of use from this tool personally and have had a lot of fun making it.
评论 #19540451 未加载
评论 #19540261 未加载
评论 #19540440 未加载
jaytaylor大约 6 年前
I&#x27;d definitely incorporate it into my projects if it were ported Go, Rust, or any reasonable redistributable form, and continued to use a BSD license. Way clearer than cryptic sed and awk one-liners! Big kudos to you for making this and sharing it with the world!<p>Python apps which are more than a single script are a non-starter for me. It&#x27;s a big pain to get everyone on my 120+ person dev team to install it properly, they&#x27;re all over the place with regard to environments. &quot;Oops, I&#x27;m on Python 3.4&quot;, or python 2.6, or &quot;I use this other python path&quot;; it&#x27;s inevitably a headache.
评论 #19541603 未加载
评论 #19545587 未加载
评论 #19540523 未加载
Sir_Cmpwn大约 6 年前
This is very cool for simplifying interactive use :) but I&#x27;d like to caution people away from immortalizing it in their scripts. sed and awk are both standardized by POSIX and can be found on pretty much any system, and trivially ported to new systems. Porting Python, on the other hand, is comparitavely a mammoth proposition, and often impossible on some platforms. For this reason, I&#x27;m generally allergic to &quot;new $x replaces $y!&quot; for any $y which is governed by portable standards.
评论 #19540380 未加载
评论 #19540383 未加载
jancsika大约 6 年前
&gt; bsed giant_malformatted.json replace &#x27;\&#x27;&#x27; with &#x27;\&quot;&#x27; | bsed replace &#x27;True&#x27; with &#x27;true&#x27; | bsed replace &#x27;False&#x27; with &#x27;false&#x27;<p>bsed giant_malformatted.json replace &#x27;\&#x27;&#x27; <i>that begins or ends a string</i> with &#x27;\&quot;&#x27; | bsed replace <i>unquoted</i> &#x27;True&#x27; with &#x27;true&#x27; | bsed replace <i>unquoted</i> &#x27;False&#x27; with &#x27;false&#x27;
评论 #19540792 未加载
mhd大约 6 年前
<p><pre><code> TEXT PROCESSING DIVISION. PERFORM REGEXP-REPLACE &quot;LETTER A; LETTER B; ONE-OR-MORE-CHARACTERS;&quot; EMPTY-STRING .</code></pre>
评论 #19543072 未加载
seiferteric大约 6 年前
Neat, but a little scary because you rely on it to interpret your intentions correctly. Usually when I am trying to do something, I build up my command in multiple steps, printing outputs and verifying it is correct before actually running the command. Maybe you could have a &quot;diff&quot; or &quot;dryrun&quot; mode that would show the potential changes. Another idea would be for this script to &quot;compile&quot; a CLI command using grep&#x2F;awk&#x2F;sed etc instead of doing the actual editing itself.
评论 #19544891 未加载
kylek大约 6 年前
Great, now I only have to google SQL syntax :)<p>(Sorry, had to take the easy one. Tooling using something as wide-spread as SQL is definitely a good thing!)
评论 #19541571 未加载
评论 #19541100 未加载
chmln大约 6 年前
How does it compare performance-wise to other tools with similar goals? Seeing this is written in 100% python, I suspect it will be an order of magnitude slower.
评论 #19540466 未加载
HerrMonnezza大约 6 年前
The HN entry title might be misleading: this is a <i>Python</i> tool, Perl is only mentioned in the Readme for comparison.
评论 #19541032 未加载
purplezooey大约 6 年前
Ah, googling for some awk wizardry. Best done with a sandwich.
salutonmundo大约 6 年前
Odd that it installs with pip but uses perl.
PhantomBKB大约 6 年前
Based
ncmncm大约 6 年前
He lost me at &quot;Perl&quot;.
评论 #19540543 未加载
评论 #19541087 未加载