From 07c56086aa0c4e015c9044e333ae4001debcb28d Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Tue, 30 Apr 2024 13:14:09 +0300 Subject: Update content for html --- gemfeed/2022-01-01-bash-golf-part-2.html | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'gemfeed/2022-01-01-bash-golf-part-2.html') diff --git a/gemfeed/2022-01-01-bash-golf-part-2.html b/gemfeed/2022-01-01-bash-golf-part-2.html index 6ff01cdf..1456d14c 100644 --- a/gemfeed/2022-01-01-bash-golf-part-2.html +++ b/gemfeed/2022-01-01-bash-golf-part-2.html @@ -8,7 +8,7 @@ -

Bash Golf Part 2


+

Bash Golf Part 2



Published at 2022-01-01T23:36:15+00:00; Updated at 2022-01-05

@@ -29,7 +29,7 @@ jgs^^^^^^^`^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2022-01-01 Bash Golf Part 2 (You are currently reading this)
2023-12-10 Bash Golf Part 3

-

Redirection


+

Redirection



Let's have a closer look at Bash redirection. As you might already know that there are 3 standard file descriptors:

@@ -161,7 +161,7 @@ First line: Learn You a Haskell Second line: for Great Good
-

HERE


+

HERE



I have mentioned HERE-documents and HERE-strings already in this post. Let's do some more examples. The following "cat" receives a multi line string from stdin. In this case, the input multi line string is a HERE-document. As you can see, it also interpolates variables (in this case the output of "date" running in a subshell).

@@ -244,7 +244,7 @@ Learn you a Golang for Great Good I like Perl too
-

RANDOM


+

RANDOM



Random is a special built-in variable containing a different pseudo random number each time it's used.

@@ -289,11 +289,11 @@ Delaying script execution for 42 seconds... Continuing script execution...
-

set -x and set -e and pipefile


+

set -x and set -e and pipefile



In my opinion, -x and -e and pipefile are the most useful Bash options. Let's have a look at them one after another.

-

-x


+

-x



-x prints commands and their arguments as they are executed. This helps to develop and debug your Bash code:

@@ -335,7 +335,7 @@ Second line: for Great Good ❯
-

-e


+

-e



This is a very important option you want to use when you are paranoid. This means, you should always "set -e" in your scripts when you need to make absolutely sure that your script runs successfully (with that I mean that no command should exit with an unexpected status code).

@@ -454,7 +454,7 @@ Hello You!
./2021-05-16-personal-bash-coding-style-guide.html

-

pipefail


+

pipefail



The pipefail option makes it so that not only the exit code of the last command of the pipe counts regards its exit code but any command of the pipe:

-- cgit v1.2.3