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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

My favorite/useful Shell Functions

5 点作者 mr_o47超过 1 年前

1 comment

chasil超过 1 年前
The &quot;function&quot; keyword is defined in ksh88, but not in the POSIX shell definition for 1992 (there were a few reasons that much ksh functionality was removed). People call this a &quot;bashism&quot; because they do not realize that the syntax originated in Korn. Debian&#x2F;Ubuntu use a POSIX system shell (dash) that does not recognize (almost) any korn&#x2F;bash extended syntax.<p>Here is my shell function to search for processes using shell patterns (these are <i>not</i> regular expressions):<p><pre><code> pps () { local a= b= c= IFS=$&#x27;\0&#x27;; ps ax | while read -r a do [ &quot;$b&quot; ] || c=1; for b; do case &quot;$a&quot; in *&quot;$b&quot;*) c=1;; esac; done; [ &quot;$c&quot; ] &amp;&amp; printf &#x27;%s\n&#x27; &quot;$a&quot; &amp;&amp; c=; done; } </code></pre> I have a fancy wrapper for .netrc password storage with SFTP, which is a little more extreme, if there is any interest.