我正在尝试通过find复制由REGEX表达式选择的图像。下面的命令会运行,但不会复制文件。如何将循环变量(例如读取文件行)传递给find -regex参数?
cat hit_images_regex_list.txt | while read line;
do
find . -regex "${line}" -exec cp --parents {} /destination_dir \;
done我从中提取REGEX表达式的hit_images_regex_list.txt文件如下所示:
".*B - 12.*tif"
".*D - 09.*tif"
".*G - 03.*tif"
".*G - 12.*tif"
...将find与这些REGEX表达式一起使用是可行的,但是从我的.txt文件中提取REGEX表达式的循环不会做任何事情。
发布于 2020-02-13 08:42:44
尝尝这个。
while IFS= read -r line; do
find . -regex "$line" -exec cp --parents {} /destination_dir \;
done < hit_images_regex_list.txthttps://stackoverflow.com/questions/60195982
复制相似问题