Wildcard in bash script

前端 未结 2 819
梦谈多话
梦谈多话 2021-01-28 01:58

I have a bash script to retrieve files from ftp.

Now the files have one part a date string in the filename, but also undefined numbers that changes on every file. I want

2条回答
  •  天涯浪人
    2021-01-28 02:47

    It sounds like you want to handle multiple files, but your script can only handle one file at a time. Furthermore, because you specified FTP, it sounds like the files are on the FTP server, in which case local filename expansion will not help.

    You probably want to use the ftp client's mget command to download multiple files matching a pattern on the remote side. You also want to include $TIMESTAMP as part of the pattern. I'd suggest something like this:

    ftp remote-hostname <

    This uses a here-document (< to EOF on a line by itself) to supply input text to the ftp commmand. It will expand the variable $TIMESTAMP so it becomes part of the mget command, e.g. if $TIMESTAMP was 12345, the ftp command will be told mget 123450???vel.radar.h5.

提交回复
热议问题