【发布时间】:2021-03-01 11:59:33
【问题描述】:
我们有 17k 个文件,其名称类似于 file1.csv、file2.csv、file3.csv ...file17000.csv。 所有这些文件都应该从一个文件夹复制到另一个文件夹。 目标是创建 Linux bash 或 python 脚本,以每 5 分钟复制所有这些文件除以“n”个 csv 文件,并防止复制“n”个已复制的文件。
想法是:
copy file1.csv file2.csv file3.csv file4.csv file5.csv to destination_dir
sleep for 300 seconds
copy file6.csv file7.csv file8.csv file9.csv file10.csv to destination_dir
sleep for 300 seconds
...
copy file16996.csv file16997.csv file16998.csv file16999.csv file17000.csv to destination_dir
对于少量文件,我们在下面的脚本中使用了在 2 个范围之间复制文件:
#!/bin/bash
source_dir='/source_dir'
target_dir='/target_dir'
echo "beginning number:$1"
echo $1
echo "finite number:$2"
echo $2
for f in $(eval ls $source_dir/file{$1..$2}.csv);
do
cp $f $target_dir
done
谁能建议如何正确指向脚本以使用下一个“n”个 csv 文件
任何意见和建议将不胜感激。
【问题讨论】:
标签: python linux shell file copy