I sent a batch of files to a remote server via SFTP. If it were a local directory I could do something like this ls -l | wc -l
to get the total number of files. However, with SFTP, I get an error Can't ls: "/|" not found
.
echo ls -l | sftp server | grep -v '^sftp' | wc -l
If you want to count the files in a directory the directory path should be put after the ls -l command like
echo ls -l /my/directory/ | sftp server | grep -v '^sftp' | wc -l
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With