0

I am using ssh in a shell script in order to go on multiple linux server and get disk information on a particular disk. I am running following but I am not able to figure out the quote sequencing...In this example I am just capturing the header for my report....

ssh dbadmin@myserver bash -c '"df -kh | grep File | awk '{ print \$1 "  |  " \$2 "  |  " \$3 "  |  " \$4 "  |  " \$5 }' | tail -n -1"'

and following error...

bash: -c: line 0: syntax error near unexpected token |' bash: -c: line 0:df -kh | grep File | awk { print | | | | } | tail -n -1'

Any help or suggestions would be great...

Thanks

2

1 Answer 1

2

Better to use quoted here-doc and avoid escaping:

ssh -t -t dbadmin@myserver<<'EOF'
df -kh | awk -v OFS="  |  " '/file/{ print $1, $2, $3, $4, $5 }' | tail -n -1
EOF
Sign up to request clarification or add additional context in comments.

1 Comment

If it worked out, you may mark the answer as accepted by clicking on tick mark on top-left of my answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.