Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何每天从一个文件夹中获取文件,并使用shell脚本将其存储在另一个文件夹中?_Shell_Unix - Fatal编程技术网

如何每天从一个文件夹中获取文件,并使用shell脚本将其存储在另一个文件夹中?

如何每天从一个文件夹中获取文件,并使用shell脚本将其存储在另一个文件夹中?,shell,unix,Shell,Unix,我需要每天在FTP位置获取文件。另一个条件是,我只需要在那个特定的一天的文件,而不是除了旧的一天的文件。然后使用shell脚本将文件存储在另一个文件夹中 更新了来自OP评论的FTP脚本 这可能会奏效: # above heredoc today=$(date +%Y%m%d) # adjust date format as required # in heredoc mget ${today}* # adjust filename pattern as required

我需要每天在FTP位置获取文件。另一个条件是,我只需要在那个特定的一天的文件,而不是除了旧的一天的文件。然后使用shell脚本将文件存储在另一个文件夹中

更新了来自OP评论的FTP脚本

这可能会奏效:

# above heredoc
today=$(date +%Y%m%d)   # adjust date format as required

# in heredoc
mget ${today}*          # adjust filename pattern as required

改掉使用ALLCAPSVAR的习惯-总有一天你会想知道为什么你的脚本会被破坏。

到目前为止,你有什么可以开始的吗?如果你有什么东西,你能添加你的代码吗?echo$HOST echo$DATASET_A echo$DATASET_B ftp-n$HOST你不能写一个cron作业,每天在ftp服务器上执行,将文件从一个目录复制到另一个目录吗?
# above heredoc
today=$(date +%Y%m%d)   # adjust date format as required

# in heredoc
mget ${today}*          # adjust filename pattern as required