Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Standard streams

As described Intro Unix: Standard streams and redirection each with a well-defined stream number:

...

Code Block
languagebash
~/workshop/step_01.sh helloWorld My name is Anna | tee step_01.log

See Standard streams and piping in the Intro Unix wiki.

When standard output and standard error streams are used

...

  • Starts automatic logging to a log file named using its 1st logFileTag argument, by calling the auto_log function.
  • Uses echo -e where the -e argument to echo enables interpretation of backslash escapes.
    • e.g. "\t" as a tab Tab character and "\n" will be interpreted as a newline.
  • Calls stdStreams with its 2nd and 3rd arguments.
  • Calls echo capturing its output in a local variable using backtick execution syntax, then displays the captured text.
  • Calls the echo_se function with some text.
  • Calls the echo_se function again, capturing its output in a local variable, then displays the captured text.

...

Expand
titleSolution

Because backtick evaluation replaces the command in backticks ( `...` ) with the echo command's standard output.

...

Expand
titleSolution

The log file produced is autoLog_test1.log, written to the current directory in force when step_02.sh was called. This name is based on the logFileTag we specified as "test1".

Its contents (below) are nearly the same as when ~/workshop/step_02.sh testAutoLog test1 is called, except that the ".. logging to ./autoLog_test1.log" line is not reported, because that was written before automatic logging was started.

Code Block
1) Call stdStreams with output and error text:
to standard output: 'text for standard output'
to standard error:  'text for standard error'

2) Capture echo output in a variable and display it:
   echo output was:
text for standard output

3) Call echo_se with error text:
text for standard error

4)Capture echo_se function output in a variable and display it:
text for standard error
echo_se output was: ''


...