I am trying to get the output from a command issued over SSH to a remote machine all on one line.
This is what I am using (from my own local machine, which is running Ubuntu 20.04 LTS) - the remote machine is running Debian 10 Buster:
Code: Select all
ssh -p22 UserA@MachineA -- 'hostnamectl | grep "Operating System" && echo -n " -- " && hostnamectl | grep "Kernel"'
whereas I would really like to get it all on one line like this:Operating System: Debian GNU/Linux 10 (buster)
-- Kernel: Linux 4.19.0-23-amd64
There are also spaces in there - I'm not worried about those, just wanting to avoid the line-feed or carriage-return. I can do that with a straight 'echo -n', but not sure how to do it with the actual commands.Operating System: Debian GNU/Linux 10 (buster) -- Kernel: Linux 4.19.0-23-amd64
Thanks in advance for any ideas or pointers!
Alan.