Following a previous answer I'm trying to list the files on an FTP server that match a pattern, as shown below
event_date=`date +%Y%m%d`
ftp -n XX.XX.XX.XX <<END_SCRIPT
ls *${event_date}* todays_files.dat
quit
END_SCRIPT
Unfortunately this does not work. Is there a way to list these files, apart from listing all files and grep'ing on the client side i.e.
event_date=`date +%Y%m%d`
ftp -n XX.XX.XX.XX <<END_SCRIPT
ls * all_files.dat
quit
END_SCRIPT
grep $event_date all_files.log > todays_files.dat
ls
in FTP will expand globs. What do you get vs what do you expect? It seems like you're expecting yourls
command in the here-document to redirect to some output file (todays_files.dat or all_files.dat) but as-written you're asking ftp'sls
to list that file on the remote side. Intended? – Jeff Schaller♦ Jul 9 at 12:38todays_files.dat
is empty i.e. no files are listed. If however I writels *20190709* today_files.dat
,todays_files.dat
contains files on the FTP server whose names contain the substring "20190709". – Olumide Jul 9 at 12:45output to local-file
); your FTP client must automatically assume that action. Do you have a peculiar FTP client? – Jeff Schaller♦ Jul 9 at 12:53