installment for the openFoam, fail to add public key

Solution 1:

You can do it with curl, which is easier in my opionin, or you can do it with wget, as I explain at the end.

With curl

Replace your command with this, and it should work.

curl -sS http://dl.openfoam.org/gpg.key | sudo apt-key add -

That command will get the key, and pipe it to sudo apt-key add -. curl, unlike wget, outputs to stdout by default, which is easier IMO.

With wget

wget as you wrote it won't work. The command was mostly correct, but you made two errors when copying it, and that messed you up. This is the proper way to write it:

sudo sh -c "wget -O - http://dl.openfoam.org/gpg.key | apt-key add -"

That is pretty much the same as what you wrote, but with two major differences. The -O after wget is capital, which is what you want to change where wget outputs to. And second, I addded a space after apt-key add, but before the hyphen, which fixes a different error.