TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

My favorite/useful Shell Functions

5 pointsby mr_o47over 1 year ago

1 comment

chasilover 1 year ago
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.