Is it possible to inject newlines in the ouput of cowsay/cowthink while preserving the "bubble"?

In order to make the nice bubble, cowsay trims all whitespaces by default. This implies line breaks. If you pass two line breaks in a row, cowsay prints both of them.

Try

cowsay "lala
lala"

vs.

cowsay "lala

lala"

The first will output lala lala in a bubble, the latter will output

lala

lala

This is not a shell related behavior, this is just cowsay :)

If you do not like this, you need the -n switch. It prevents word wrapping completely and therefore allows arbitrary whitespace characters.

Unfortunately, the following command does not work as excepted:

cowsay -n "lala
lala"

Because cowsay does in my version not allow passing a message as argument while -n option is given. But

echo "lala
lala" | cowsay -n

works as a charm.

So for your problem, if you don't like the double \n in your output, change the command to

(echo "BASH manual - $(links -dump 'http://git.savannah.gnu.org/cgit/bash.git/tree/doc/bash.1' | grep -om 1 'Last Change.*')"; echo "Local BASH manual - $(zcat /usr/share/man/man1/bash.1.gz | grep -om 1 'Last Change.*')"; echo "BASH repo /doc: $(links -dump 'http://git.savannah.gnu.org/cgit/bash.git/log/doc' | grep -Eom 1 '[[:digit:]]{4}-[[:digit:]]{2}-[[:digit:]]{2}')"; echo "BASH Reference man(www): $(links -dump 'http://www.gnu.org/software/bash/manual' | grep -om 1 'last updated.*')") \
| cowthink -f tux -n

Tags:

Cowsay