The grep shell command isn’t built into the standard SFTP environment, so in order to use grep on a remote file, you will need to transfer the file to the local computer with SFTP and then perform a grep.