我在PHP中构建了一个FTP类,它具有从FTP服务器下载文件的功能。
这是目前为止的功能。
public function downloadData($serverFile, $localPath)
{
$fileName = basename($serverFile);
$file = $localPath.$fileName;
$download = false;
if(!file_exists($file))
{
// try to download $server_file and save
我正在制作一个bash脚本,在包含每天生成的文件的目录中运行,并将最新的文件复制到另一个目录。
我现在正在用这个
for [FILE in directory]
do
if [ls -Art | tail -n 1]
something...
else
something...
fi
done
我知道这是不对的。我想将文件的修改日期与当前日期进行比较,如果相等,则复制该文件。
这是如何工作的,或者有一种更简单的方法来实现?
我正在将一个文件夹及其所有内容(包括子目录和文件)导入到我的应用程序数据目录中,以供应用程序使用。 我尝试了许多解决方案,但有效的解决方案是这样的。 //Create all of the directories
foreach (string dirPath in Directory.GetDirectories(SourcePath, "*",
SearchOption.AllDirectories))
Directory.CreateDirectory(dirPath.Replace(SourcePath, DestinationPath));
//Copy all
我的测试设备生成大型文本文件,随着数据的添加,这些文本文件的大小往往会在几天内增加。
但是,文本文件每天都会被传输到PC机进行备份,甚至在它们还没有完成增长之前,就会在这里使用gzip进行压缩。
这意味着我经常使用file.txt和压缩表单file.txt.gz,其中未压缩的文件可能比压缩版本更最新。
我决定在下面的bash脚本gzandrm中保留哪一个
#!/usr/bin/bash
# Given an uncompressed file, look in the same directory for
# a gzipped version of the file and delete