-q option to tell
sftp to be quiet, thereby suppressing most of the output you don't care about:
echo "ls *.txt" | sftp -q email@example.com:/path
You will still see the lines for the interactive prompt to which you are echoing, e. g.
sftp> ls *.txt, but those can be filtered out with a
echo "ls *.txt" | sftp -q firstname.lastname@example.org:/path | grep -v '^sftp>`
As an aside, it's probably better practice to use a batch file, and pass it with the
-b parameter to
sftp rather than
echoing a pipeline into it.
If all you really want to do is get a list of files, this might actually be better served with
ssh than with
sftp (which, after all, is the secure file transfer program):
ssh email@example.com ls -1 /path