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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Cat without cat on the commandline (2020)

25 点作者 zoidb7 个月前

8 条评论

basemi7 个月前
The main purpose of `cat` is not to print a single file to stdout but to conCATenate files to stdout [0]. Of course if I have a single file it&#x27;s printed alone. Just here to say that `cat` is not a synonym of `print`, but nowadays it&#x27;s &quot;cat FILE&quot; everywhere. Even in APIs... [1] (Compact and aligned text? XD)<p>[0] <a href="https:&#x2F;&#x2F;www.man7.org&#x2F;linux&#x2F;man-pages&#x2F;man1&#x2F;cat.1.html" rel="nofollow">https:&#x2F;&#x2F;www.man7.org&#x2F;linux&#x2F;man-pages&#x2F;man1&#x2F;cat.1.html</a> [1] <a href="https:&#x2F;&#x2F;www.elastic.co&#x2F;guide&#x2F;en&#x2F;elasticsearch&#x2F;reference&#x2F;current&#x2F;cat.html" rel="nofollow">https:&#x2F;&#x2F;www.elastic.co&#x2F;guide&#x2F;en&#x2F;elasticsearch&#x2F;reference&#x2F;curr...</a>
评论 #41901783 未加载
silisili7 个月前
Shell scripting is one of those places where readability is king, and premature optimization is the devil.<p>Yes, there are multiple ways to get by without cat. Are they as obvious to understand? If not, what are we doing?<p>Shell scripting isn&#x27;t meant for performance but composability. If you&#x27;re fighting me over micro optimizations, I&#x27;m just going to rewrite it in a proper language and 100x its performance. But then it&#x27;s lost its readability and it&#x27;s no longer editable.<p>Balance, like most things in life.
评论 #41909061 未加载
jwilk7 个月前
Related: <a href="https:&#x2F;&#x2F;github.com&#x2F;wader&#x2F;catgolf">https:&#x2F;&#x2F;github.com&#x2F;wader&#x2F;catgolf</a> (might not be completely serious)
ilyagr7 个月前
Took me a bit to figure out a nice way to do this in the `fish` shell. I think it&#x27;s `string collect &lt; file.txt`.
ChrisArchitect7 个月前
Related:<p><i>The useful use of cat</i><p><a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=41894933">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=41894933</a>
vman817 个月前
If I didn&#x27;t have manpages or the option to google I&#x27;d probably just use head or tail after doing &#x27;wc -l&#x27; to determine line count.<p>head filename -n `wc -l filename`
评论 #41901977 未加载
optymizer7 个月前
On what kind of Linux system do you get a shell but don&#x27;t have access to `cat`?
评论 #41901553 未加载
评论 #41901641 未加载
its-summertime7 个月前
the read&#x2F;echo loop will not handle nulls<p>the command substitution will mangle ending newlines