2

Note: This is not a duplicate of 2597394.

I have an FTP server (Unix or Linux) with a folder that contains the following files (for example):

  • filename.txt
  • filename.txt.abc
  • filename

When I issue mget file* command to ftp or sftp, I can fetch all three files. What I need to do is to fetch only the filename file (the one without any extension).

I tried grep and | but these aren't recognized by the ftp or sftp commands' prompt. I also tried --exclude but the mget here doesn't even support any options. The man page is something like this.

How do I solve this problem? I cannot specify the exact filename as it's not known. It must be a wild card.

Community
  • 1
  • 1
ADTC
  • 8,999
  • 5
  • 68
  • 93

1 Answers1

0

Although not an exact solution to the original problem, I created a workaround as follows. The workaround will still get all the three files, but it will then use the rm shell command to delete the files with extensions.

mget   file*
!rm -f file*.*

Only the file without extension will remain after the operation is completed. Note that ! tells ftp or sftp to execute what's on its right using the local shell. A potential problem with this workaround is the inadvertent deletion of existing local files.

ADTC
  • 8,999
  • 5
  • 68
  • 93