HackerURLs

一次又一次被重新发现的经典。

同一个链接,相隔一年以上,一次又一次被人重新发现、再次冲上 Hacker News 首页。能经受住这种时间检验的,大多是值得一读再读的文章。每篇附中文标题,讨论最热的那些再加上中文导读和高赞评论翻译。

从名人堂开始
  • 4,700+篇经过时间检验的经典

Hall of fame

名人堂

在经典库里看全部精选

上首页次数最多、而且有中文导读的 30 篇。时间轴上每个黑点是一次上首页,空心点是一次没冲上去的投稿。

  1. 正在载入经典…

Archive

经典库

按第一次上首页的年份分布,点柱子筛选。

排序

    About

    这些经典是怎么挑出来的

    1. 01

      合并同一个链接

      读取 Hacker News 自 2006 年以来的全部链接投稿,把 http/https、www、跟踪参数等写法不同的同一篇文章合并成一条。

    2. 02

      只留经得起时间的

      同一链接至少两次拿到 50 分以上(约等于上首页),而且两次相隔一年以上;再由 AI 剔除状态页、产品首页和新闻事件。

    3. 03

      写导读、译评论

      上首页次数最多的 2,000 篇配上中文导读、"为什么经久不衰",并精选翻译 HN 高赞评论。导读由 AI 生成,可能有误。

    工具与资源github.com

    Bash 一行命令合集与终端技巧

    Bash-oneliner: A collection of handy Bash one-liners and terminal tricks

    2次上首页
    2年跨度
    600累计得分
    170条评论

    2022 — 2024,它一次次回到首页

    黑点是上首页(≥ 50 分)的那次投稿,空心点是没冲上去的投稿,点越大分数越高。

    导读

    这个 GitHub 仓库整理了大量实用的 Bash 单行命令和终端小技巧,方便在日常命令行工作中查找和组合使用。内容偏速查手册,评论区也补充了不少命令、工具和可移植性提醒。

    为什么经久不衰:因为它把高频但零散的 shell 技巧集中成可检索的速查表,并有社区持续补充,所以多年后仍是命令行用户的实用参考。

    关键词 Bash命令行单行命令速查表

    HN 评论精选

    补充了 $()、readlink -f、cp -a、lndir 等遗漏技巧,并解释 lndir 的符号链接复制用法。

    我很惊讶这份(否则相当全面的)清单里居然没有 $()。虽然列出的少数命令用到了它,但它绝对值得单独成条。还有用 readlink -f 获取文件绝对路径(macOS 上不行;我找到的唯一替代是安装 greadlink)。以及 cp -a,它类似 cp -r,但会保留权限,意味着你可以前面加 sudo 而不用再费劲把所有权改回来。我也从没在这些清单里见过 lndir:它会复制一个目录,但目标目录中的所有非目录文件都会被替换成指回源文件的符号链接,而目录结构原样保留;也就是说,当你 cd 进去时,实际进入的是源目录的一个复制结构,而不是像直接给源文件夹做符号链接那样进入源目录本身。进去之后,任何你想修改又不影响原件的文件,只需要把符号链接换成文件,可以用 sed -i '' $symlink 做到。这样你就得到了一个实际效果上等于原目录副本的东西,而只有被修改的文件才真正占用空间(粗略地说)。看来我有几个 PR 要提。

    archduck查看英文原文

    I was surprised to see `$()` missing from this (otherwise quite extensive) list. There are a few commands listed which employ it, but it absolutely deserves its own entry. That and `readlink -f` to get the absolute path of a file. (Doesn't work on MacOS; the only substitute I've found is to install `greadlink`.) And `cp -a`, which is like `cp -r`, but it leaves permissions intact - meaning that you can prepend `sudo` without the hassle of changing the ownership back. I never see `lndir` on these lists either. It makes a copy of a directory, but all of the non-directory files in the target are replaced with symlinks back to the source while directories are preserved as-is. Meaning that when you `cd` into it, you are actually landing in a copied structure of the source directory instead of the source directory itself, as would be the case if you just symlinked the source folder. Once inside, any file you want to modify without affecting the original just needs you to create the symlink into a file, which you can do with `sed -i '' $symlink`. There you have it: effectively a copy of your original directory, with only the modified files actually taking up space (loosely speaking). Looks like I have a few pull requests to submit.

    推荐 shellcheck、shfmt、sub、bashdb 等 Bash 工程化工具,并指出模块共享仍是缺口。

    这些不算单行命令,但我发现有些工具对处理大型 Bash 代码库很有帮助:shellcheck 和 shfmt 用于检查和格式化;sub 用于组织子命令;bashdb 用于通过 VSCode 扩展交互式调试脚本。我仍然缺少像 ansible/terraform 那样与他人共享模块的方法,但还没找到最佳方式。

    bfm查看英文原文

    Not one-liners, but some of the tools that I have found helpful for working with large bash codebases are: - shellcheck and shfmt for linting and formatting - sub for organizing subcommands - bashdb for debugging scripts interactively via the VSCode extension I'm still missing a way to share modules with others like it can be done with ansible/terraform, but I have not found an optimal way to do it yet. [shellcheck] https://github.com/koalaman/shellcheck [shfmt] https://github.com/mvdan/sh [sub] https://github.com/qrush/sub [bashdb] http://bashdb.sourceforge.net/ [vscode-bash-debug] https://github.com/rogalmic/vscode-bash-debug

    提醒 sed -i 的可移植性差异,并分享用转义序列设置终端/tmux 标题的技巧。

    sed -i 要小心,这是 Linux 特有的写法,macOS 的 sed 会把它后面的内容当作备份表达式;据我所知,最安全的选择是始终指定备份扩展名,比如 sed -i~ 或 sed -i.bak,以保持可移植性,尽管有很多变通方法去检测到底是哪种并写 ${SED_I} -e whatever 之类的傻办法。我的贡献(我知道,去提 PR……)是我从脚本设置终端标题中获益很多:title() { printf '\033]0;%s\007' "$*"; };tmux 也有一个:printf '\033]2;%s\007' "$*";。还有两个极其有用的资源:xfree86 控制序列文档和 iTerm2 转义码文档。

    mdaniel查看英文原文

    sed -i Watch out, that's a Linux-ism and macOS's sed will cheerfully use the thing after it as the backup expression; as far as I know, the absolute safest choice is to always specify a backup extension "sed -i~" or "sed -i.bak" to make it portable, although there are plenty of work-arounds trying to detect which is which and "$ {SED_I} -e whatever" type silliness My contribution (and yeah, I know, PR it ...) is that I get a lot of mileage out of setting the terminal title from my scripts: title() { printf '\033]0;%s\007' "$*"; } and there's one for tmux, too printf '\033]2;%s\007' "$*"; with the two infinitely handy resources: * https://www.xfree86.org/current/ctlseqs.html * https://iterm2.com/documentation-escape-codes.html

    称赞合集全面,并推荐 Effective Shell 系列作为延伸学习材料。

    这是一份很好且非常全面的合集。作为后续,我还可以推荐 Effective Shell 系列。我以前把 Part 1 里的导航快捷键图打印出来放在手边。

    archielc查看英文原文

    That's a nice and very extensive collection. As a follow-up, I can also recommend Effective Shell series. I used to have navigation shortcut diagram from Part 1 (https://dwmkerr.com/effective-shell-part-1-navigating-the-command-line/) printed out.

    历次讨论

    同类还值得读

    1. 直接在浏览器中启动 Linux 内核

      Boot a linux kernel right inside your browser.

      Fabrice Bellard 的 JSLinux 页面,用 JavaScript 在浏览器里启动一个 Linux 内核,并提供一个可交互的终端环境。

      工具与资源上首页 5 次 · 2011–2025bellard.org
    2. Hacker News 未公开功能与行为清单(2018)

      A List of Hacker News's Undocumented Features and Behaviors (2018)

      数据科学家 Max Woolf 整理的 Hacker News 未公开功能与行为清单,涵盖投票机制、排名算法、账号惩罚等社区运作细节。

      工具与资源上首页 5 次 · 2019–2025github.com
    3. MapSCII:在终端中用盲文和 ASCII 渲染地图

      MapSCII – Braille and ASCII map renderer for the console

      MapSCII 是一个在命令行终端里渲染地图的开源工具,用盲文字符和 ASCII 字符把地理数据画成可交互浏览的字符地图。

      工具与资源上首页 5 次 · 2017–2025github.com
    4. 顶尖大学的免费在线课程

      Free Online Courses from Top Universities

      Open Culture 整理的一份免费在线课程合集,汇集了全球顶尖大学(如 MIT、斯坦福、耶鲁等)向公众开放的网络课程资源,涵盖音频、视频等多种形式。

      工具与资源上首页 5 次 · 2010–2022openculture.com
    5. 淘气字符串:容易引发用户输入问题的字符串清单

      Naughty Strings: A list of strings likely to cause issues as user-input data

      一个 GitHub 仓库,收录了大量容易让程序出问题的用户输入字符串,如特殊字符、emoji、SQL 注入片段、系统命令等,供开发者用于测试输入处理逻辑。

      工具与资源上首页 4 次 · 2015–2020github.com

    打赏支持

    打赏二维码

    觉得有用,请作者喝杯咖啡。

    WeChat

    关注向阳乔木

    微信公众号「向阳乔木推荐看」

    微信公众号「向阳乔木推荐看」二维码

    微信扫一扫;在微信里打开本页时,长按二维码识别。