I have a command processing function that runs its arguments and outputs the results to a file. The outputs of those commands must now be PROCESSED just before going to the file.
I have only one requirement: echo "var is: $var"
must show the outcome which will be used further down in the code.
THIS BREAKS MY REQUIREMENT: "${@:1}" | perl -pe 's/\**//g' >> './test.log'
I imagine something like this:
"${@:1}" 1>> perl -pe 's/\**//g' >> './test.log'
but it does not work.
I have simplified my code down to the following:
process() {
"${@:1}" 1>>'./test.log'
}
process eval 'var=$(echo -e "*****ONE *****WORD"); echo -e "$var";'
echo "var is: $var"
Currently this function outputs:
screen :"var is: *****ONE *****WORD"
logfile:"*****ONE *****WORD"
.
Required result:
screen :"var is: *****ONE *****WORD"
logfile:"ONE WORD"
How can I achieve this?
PS. muru asked me why I use eval. I answered, because there is no other way to populate the variable without duplicating code. Unfortunately our discussion under his answer was deleted.