title: Count number of files in a remote directory using SFTP
body: <p>I am writing a script in bash and I need to count how many files starting with ddd that are in a remote directory using SFTP. After it download each file, so them I can compare how many files had in the remote directory and how many files were downloaded. Check if they match and such.</p>
  
  <p>I was doing something like this:</p>
  
  <p><code>echo ls -l | sftp "user@$123.45.67.8:/home/user/datafolder/ddd*" | wc -l</code></p>
  
  <p>The one above works, but when I run this it downloads all the files to my local folder, which I do not want.</p>
  
  <p>How can I count the number of files and do not download them. I want to download them in another part of the code.</p>