Following is the command which is in shell script.

var="$(sshpass -p  'password' ssh -o "StrictHostKeyChecking=no" username@hostip <<-EOF
command to run on remote host

when i echo $var, output is displayed without spaces and new line i.e, trimming spaces and new lines. i need complete output from the remote host with spaces and new line.

On Running Manually through CLI, getting correct output i.e, with spaces and line. But on echoing the varibale($var) output getting trimmed.

tried this echo ${var}, still no luck, getting output trimmed of white spaces and new line.

marked as duplicate by steeldriver, Rui F Ribeiro, roaima, Romeo Ninov, Kusalananda bash Jan 29 at 19:20

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

Browse other questions tagged or ask your own question.