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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Tips for writing efficient Bash scripts

26 点作者 quoderat超过 16 年前

2 条评论

hernan7超过 16 年前
This stuff is good to know -- I have found the "sed -e" trick and doing pattern matching inside awk help cut down on typing quite a bit. They may even make the script more readable, once you become familiar with these idioms.<p>On the other hand, I don't know if these type of performance optimizations will have many real-world applications. For example, if you are calling grep and awk inside a loop, and find it unacceptable slow, I don't think you are going to see a big performance gain by calling only awk. At that point, your best bet may be to write that part of your script in Perl (or C, like I did once back in the times before Perl was mainstream).
greg超过 16 年前
Is it just me or do most of these seem like premature optimization? I would rather use one command for filtering lines (grep) and another for filtering columns (awk) than try to do both at once.
评论 #462591 未加载
评论 #462562 未加载