Reputation: 218
Is it possible to cache or save the result of lolcat in a variable and print the result out later like so:
RESULT=$(echo mytext | lolcat);
echo $RESULT
The result is missing color formatting.
Upvotes: 1
Views: 994
Reputation: 782025
lolcat
checks whether the output is going to a terminal. When you use command substitution, the output goes to a pipe, so it doesn't output color change codes.
Use the --force
option to override this. And quote the variable to prevent whitespace from being collapsed.
result=$(echo mytext | lolcat --force)
echo "$result"
Upvotes: 3