0
votes

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

filename.1391911
filename.2391911
filename.xml

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

filename.1* and filename.2* i dont want filename.xml

mget filename.1* and mget filename.2* does not work in ftp

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.

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

2
why not just mget filename.* and remove the .xml file afterwards. As for the filename.1* stuff, sftp will use the same globbing capabilities as the shell you'd normally be using if you'd ssh'd in to.Marc B
Thanks Mark.The only problem with doing so is there are some other apps running on the downloaded folder to pick up files the moment its placed it. So it might get picked up before I get a chance to remove them; which might be a big issue as the application wont recognize this format.Smitha Kalluz
Also I was wondering why mget filename.1* wont work? Any ideasSmitha Kalluz

2 Answers

0
votes

you can use regex format. i use ([a-zA-Z0-9\s_\.-():])+(.xml|.csv|.pdf)$ for my files

https://www.regextester.com/100077

0
votes

You can use

mget -O . . '[a-z A-Z]*.^[xml]'

The above command will fetch files from your current FTP location and download them to current location on shell prompt. The filter the REGEX would apply is get all files with a-z A-Z name and exclude .xml files