summaryrefslogtreecommitdiff
path: root/gemfeed/2021-11-29-bash-golf-part-1.html
diff options
context:
space:
mode:
Diffstat (limited to 'gemfeed/2021-11-29-bash-golf-part-1.html')
-rw-r--r--gemfeed/2021-11-29-bash-golf-part-1.html60
1 files changed, 39 insertions, 21 deletions
diff --git a/gemfeed/2021-11-29-bash-golf-part-1.html b/gemfeed/2021-11-29-bash-golf-part-1.html
index 4bccd556..529941d3 100644
--- a/gemfeed/2021-11-29-bash-golf-part-1.html
+++ b/gemfeed/2021-11-29-bash-golf-part-1.html
@@ -8,10 +8,19 @@
<link rel="stylesheet" href="style-override.css" />
</head>
<body>
-<h1 style='display: inline'>Bash Golf Part 1</h1><br />
+<p class="header">
+<a href="https://foo.zone">Home</a> | <a href="https://codeberg.org/snonux/foo.zone/src/branch/content-md/gemfeed/2021-11-29-bash-golf-part-1.md">Markdown</a> | <a href="gemini://foo.zone/gemfeed/2021-11-29-bash-golf-part-1.gmi">Gemini</a>
+</p>
+<h1 style='display: inline' id='bash-golf-part-1'>Bash Golf Part 1</h1><br />
<br />
<span class='quote'>Published at 2021-11-29T14:06:14+00:00; Updated at 2022-01-05</span><br />
<br />
+<span>This is the first blog post about my Bash Golf series. This series is about random Bash tips, tricks and weirdnesses I came across. It&#39;s a collection of smaller articles I wrote in an older (in German language) blog, which I translated and refreshed with some new content.</span><br />
+<br />
+<a class='textlink' href='./2021-11-29-bash-golf-part-1.html'>2021-11-29 Bash Golf Part 1 (You are currently reading this)</a><br />
+<a class='textlink' href='./2022-01-01-bash-golf-part-2.html'>2022-01-01 Bash Golf Part 2</a><br />
+<a class='textlink' href='./2023-12-10-bash-golf-part-3.html'>2023-12-10 Bash Golf Part 3</a><br />
+<br />
<pre>
&#39;\ . . |&gt;18&gt;&gt;
\ . &#39; . |
@@ -23,12 +32,20 @@ jgs^^^^^^^`^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Art by Joan Stark
</pre>
<br />
-<span>This is the first blog post about my Bash Golf series. This series is about random Bash tips, tricks and weirdnesses I came across. It&#39;s a collection of smaller articles I wrote in an older (in German language) blog, which I translated and refreshed with some new content.</span><br />
+<h2 style='display: inline' id='table-of-contents'>Table of Contents</h2><br />
<br />
-<a class='textlink' href='./2021-11-29-bash-golf-part-1.html'>2021-11-29 Bash Golf Part 1 (You are currently reading this)</a><br />
-<a class='textlink' href='./2022-01-01-bash-golf-part-2.html'>2022-01-01 Bash Golf Part 2</a><br />
-<br />
-<h2 style='display: inline'>TCP/IP networking</h2><br />
+<ul>
+<li><a href='#bash-golf-part-1'>Bash Golf Part 1</a></li>
+<li>⇢ <a href='#tcpip-networking'>TCP/IP networking</a></li>
+<li>⇢ <a href='#process-substitution'>Process substitution</a></li>
+<li>⇢ <a href='#grouping'>Grouping</a></li>
+<li>⇢ <a href='#expansions'>Expansions</a></li>
+<li>⇢ <a href='#--aka-stdin-and-stdout-placeholder'>- aka stdin and stdout placeholder</a></li>
+<li>⇢ <a href='#alternative-argument-passing'>Alternative argument passing</a></li>
+<li>⇢ <a href='#-aka-the-null-command'>: aka the null command</a></li>
+<li>⇢ <a href='#no-floating-point-support'>(No) floating point support</a></li>
+</ul><br />
+<h2 style='display: inline' id='tcpip-networking'>TCP/IP networking</h2><br />
<br />
<span>You probably know the Netcat tool, which is a swiss army knife for TCP/IP networking on the command line. But did you know that the Bash natively supports TCP/IP networking?</span><br />
<br />
@@ -62,7 +79,7 @@ X-Frame-Options: SAMEORIGIN
<br />
<span>You would assume that this also works with the ZSH, but it doesn&#39;t. This is one of the few things which don&#39;t work with the ZSH but in the Bash. There might be plugins you could use for ZSH to do something similar, though.</span><br />
<br />
-<h2 style='display: inline'>Process substitution</h2><br />
+<h2 style='display: inline' id='process-substitution'>Process substitution</h2><br />
<br />
<span>The idea here is, that you can read the output (stdout) of a command from a file descriptor:</span><br />
<br />
@@ -142,7 +159,7 @@ foo bar baz
<br />
<span>Just think a while and see whether you understand fully what is happening here.</span><br />
<br />
-<h2 style='display: inline'>Grouping</h2><br />
+<h2 style='display: inline' id='grouping'>Grouping</h2><br />
<br />
<span>Command grouping can be quite useful for combining the output of multiple commands:</span><br />
<br />
@@ -209,7 +226,7 @@ $ Expands to the process ID of the shell. In a () subshell, it expands to
1028739
</pre>
<br />
-<h2 style='display: inline'>Expansions</h2><br />
+<h2 style='display: inline' id='expansions'>Expansions</h2><br />
<br />
<span>Let&#39;s start with simple examples:</span><br />
<br />
@@ -266,7 +283,7 @@ one:A one:B one:C two:A two:B two:C
Linux-one:A-FreeBSD Linux-one:B-FreeBSD Linux-one:C-FreeBSD Linux-two:A-FreeBSD Linux-two:B-FreeBSD Linux-two:C-FreeBSD Linux-three:A-FreeBSD Linux-three:B-FreeBSD Linux-three:C-FreeBSD
</pre>
<br />
-<h2 style='display: inline'>- aka stdin and stdout placeholder</h2><br />
+<h2 style='display: inline' id='--aka-stdin-and-stdout-placeholder'>- aka stdin and stdout placeholder</h2><br />
<br />
<span>Some commands and Bash builtins use "-" as a placeholder for stdin and stdout:</span><br />
<br />
@@ -317,7 +334,7 @@ $ file -
/dev/stdin: Perl script text executable
</pre>
<br />
-<h2 style='display: inline'>Alternative argument passing</h2><br />
+<h2 style='display: inline' id='alternative-argument-passing'>Alternative argument passing</h2><br />
<br />
<span>This is a quite unusual way of passing arguments to a Bash script:</span><br />
<br />
@@ -359,7 +376,7 @@ paul:secret
<br />
<span>But the downside of it is that the variables will also be defined in your current shell environment and not just in the scripts sub-process.</span><br />
<br />
-<h2 style='display: inline'>: aka the null command</h2><br />
+<h2 style='display: inline' id='-aka-the-null-command'>: aka the null command</h2><br />
<br />
<span>First, let&#39;s use the "help" Bash built-in to see what it says about the null command:</span><br />
<br />
@@ -446,7 +463,7 @@ bash: 1: command not found...
4
</pre>
<br />
-<h2 style='display: inline'>(No) floating point support</h2><br />
+<h2 style='display: inline' id='no-floating-point-support'>(No) floating point support</h2><br />
<br />
<span>I have to give a plus-point to the ZSH here. As the ZSH supports floating point calculation, whereas the Bash doesn&#39;t:</span><br />
<br />
@@ -473,20 +490,21 @@ bash: line 1: 1/10.0 : syntax error: invalid arithmetic operator (error token is
<br />
<span>See you later for the next post of this series.</span><br />
<br />
+<span>E-Mail your comments to <span class='inlinecode'>paul@nospam.buetow.org</span> :-)</span><br />
+<br />
<span>Other related posts are:</span><br />
<br />
-<a class='textlink' href='./2021-05-16-personal-bash-coding-style-guide.html'>2021-05-16 Personal Bash coding style guide</a><br />
-<a class='textlink' href='./2021-06-05-gemtexter-one-bash-script-to-rule-it-all.html'>2021-06-05 Gemtexter - One Bash script to rule it all</a><br />
-<a class='textlink' href='./2021-11-29-bash-golf-part-1.html'>2021-11-29 Bash Golf Part 1 (You are currently reading this)</a><br />
+<a class='textlink' href='./2023-12-10-bash-golf-part-3.html'>2023-12-10 Bash Golf Part 3</a><br />
<a class='textlink' href='./2022-01-01-bash-golf-part-2.html'>2022-01-01 Bash Golf Part 2</a><br />
-<br />
-<span>E-Mail your comments to <span class='inlinecode'>paul@nospam.buetow.org</span> :-)</span><br />
+<a class='textlink' href='./2021-11-29-bash-golf-part-1.html'>2021-11-29 Bash Golf Part 1 (You are currently reading this)</a><br />
+<a class='textlink' href='./2021-06-05-gemtexter-one-bash-script-to-rule-it-all.html'>2021-06-05 Gemtexter - One Bash script to rule it all</a><br />
+<a class='textlink' href='./2021-05-16-personal-bash-coding-style-guide.html'>2021-05-16 Personal Bash coding style guide</a><br />
<br />
<a class='textlink' href='../'>Back to the main site</a><br />
<p class="footer">
-Generated by <a href="https://codeberg.org/snonux/gemtexter">Gemtexter 2.1.0-release</a> |
-served by <a href="https://www.OpenBSD.org">OpenBSD</a>/<a href="https://man.openbsd.org/httpd.8">httpd(8)</a> |
-<a href="https://www.foo.zone/site-mirrors.html">Site Mirrors</a>
+Generated with <a href="https://codeberg.org/snonux/gemtexter">Gemtexter 3.0.1-develop</a> |
+served by <a href="https://www.OpenBSD.org">OpenBSD</a>/<a href="https://man.openbsd.org/relayd.8">relayd(8)</a>+<a href="https://man.openbsd.org/httpd.8">httpd(8)</a> |
+<a href="https://foo.zone/site-mirrors.html">Site Mirrors</a>
</p>
</body>
</html>