SFTP: return number of files in remote directory?
问题 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 . 回答1: 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 回答2: Use a batch file to run commands