Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • 2
    As far as I recall, command substitution $( ... ) is performed in a sub-shell and therefore cannot modify the variables of the shell from which it is called. Can you for test reasons check what happens if you simply call f_my_func without placing it in the $( ... ) construct? Commented Jan 31, 2020 at 14:39
  • It is a specific need... The original function is huge so I would like to keep the outputs of this function (echo basically) in a log file that is generated with the entry in F_MY_FUNC_R. Thanks! =D Commented Jan 31, 2020 at 14:44
  • 1
    If you want the output in a log file why don't you just redirect the output to a log file? Commented Jan 31, 2020 at 14:47
  • Because the logging scheme is made up of many legacy components. Apparently, if I can redirect stdout to a variable, I will be able to solve the problem. This works: f_my_func > f_my_func_op; F_MY_FUNC_R=$(cat f_my_func_op); rm -f "f_my_func_op". Commented Jan 31, 2020 at 14:57