The code below works ok, however; I need to output the results to a local variable
the_path="/mnt/back/hang"
ssh -T -i /home/buddy/.ssh/id_rsa buddy@ginger << EOF
find ${the_path} -name "*.jpg" | wc -l > ## output to local variable
exit
EOF
The code below works ok, however; I need to output the results to a local variable
the_path="/mnt/back/hang"
ssh -T -i /home/buddy/.ssh/id_rsa buddy@ginger << EOF
find ${the_path} -name "*.jpg" | wc -l > ## output to local variable
exit
EOF
VAR="$(ssh -T -i /home/buddy/.ssh/id_rsa buddy@ginger find ${the_path} -name "*.jpg" '|' wc -l)"
Thanks,
I have a few more directories to search on the host, that's why I attempted to do it via a here doc
You can cram as many directories as you want into one find, no need to run it repeatedly. You may wish to redirect stderr in case some of them don't exist ... 2>/dev/null