Pipe text in to find command

I would like to know why this command does not work.
I have a script which connects to and ftp site.
After getting the remote files localy i need move each remote file to a archive folder on the FTP site

*Please also note that some of the files have spaces in the file name.

Im trying to extract the list of files names from the temp output file temp_rem_file_list.

 
echo "$TIME_STAMP - TEST MODE"
REMOTE_FILELIST=`ftp -in <<EOF
open $REMOTE_SERVER
user $USER $PW
cd $IN_REMOTE_SOURCE_DIR
ls
quit
 
echo $REMOTE_FILE_LIST > temp_rem_file_list
cat temp_rem_file_list
cat temp_rem_file_list |find "*.txt" -printf %f\\n >downloadList
echo "$TIME_STAMP - Printing download list"
cat downloadList
rm temp_rem_file_list
 
 
for SERVER_FILE in `cat downloadList`
 do
 echo "$TIME_STAMP - Server file processing is $SERVER_FILE"
   if [ -e "$IN_LOCAL_TARGET_DIR/$SERVER_FILE" ];then
   #if the file exists on the local machine
   else
   #File does not exist 
 fi

contents of temp_rem_file_list

 open localhost user if_jjan welcome1 cd Out ls drw-rw-rw- 1 ftp ftp 0 Jan 27 11:40 . drw-rw-rw- 1 ftp ftp 0 Jan 27 11:40 .. drw-rw-rw- 1 ftp ftp 0 Jan 26 00:33 archive -rw-rw-rw- 1 ftp ftp 0 Jan 27 11:21 test.txt -rw-rw-rw- 1 ftp ftp 0 Jan 27 11:22 UBS-test 1 test.txt -rw-rw-rw- 1 ftp ftp 0 Jan 27 11:23 UBS-test 2 test.txt quit

Line of code giving the problem.

 
cat temp_rem_file_list |find "*.txt" -printf %f\\n >downloadList 

Im expecting downloadList to contain the following file names
test.txt
UBS-test 1 test.txt
UBS-test 2 test.txt

Thank you in advance for your time and for any pointers.

find doesn't read from standard input, that's why. find doesn't read text at all, really -- find searches folders for files, not files for strings.

grep or awk would be more suitable for extracting data from a file.

I think your data got garbled, all the linefeeds ripped out. Could you post again with the linefeeds, and put it in code tags?

Thanks for your reply. The code does work on the CMD but when i add it to the bash script it fails.

Sorry, the script posted contains too many scripting errors to follow exactly what it was intended to do. I get the gist of finding out what files are present on the remote server, then transferring them.

What might be useful is to post sample output from a ftp session showing the exact format of:

ls
# And just in case these commands work on your system and give a more useful format when in a ftp session:
ls -1
dir
dir /b

Further to Corona688 the MSDOS "find" command is more like a very basic unix "grep" command. There the similarity ends.

There is a little-used syntax to the "ftp" command "dir" which outputs the results of the "dir" to a local file. This should help us isolate the output from "dir" from the general "ftp" session output.

Are you able to post a representative command-prompt session which works - along with a bit of anotation about what you are trying to achieve along with sample input data and expected output. Some sample data showing "with spaces" and "without spaces" would help. We are particularly interested in how you dealt with filenames containing space characters in the command-prompt session.

As usual it always helps to post what Operating Systems and versions are involved in a file transfer problem.

Footnote: We have to get rid of those "for" statements if any of the filenames contain space characters. I continue to wonder where this syntax comes from as I have never seen it in a book or training material.