搜索泥称 发表于 2018-8-26 09:35:23

shell脚本之对不存的文件进行记录

  在工作中经常遇到在一个文件中记录了许多文件名或者图片名,在指定的目录下对需要找到此文件中所有文件,但指定目录下并没有文件中记录的所有名字,此时需要在指定目录下找到此文件中记录了的所有文件,如果不存在则对此文件进行记录!
  脚本实例:
  在pic.txt记录了所有需要找到的文件名
# cat find_pic.sh  
#!/bin/bash
  
cat pic.txt | while read line
  
do
  
if [ -f /usr/local/war/static/ftp_product_img/$line ];then
  
    find /usr/local/war/static/ftp_product_img/ -name $line -exec cp {} /tmp/pic \;
  
else
  
    echo "$line not_exist!" >> /tmp/find_pic.log
  
fi
  
done


页: [1]
查看完整版本: shell脚本之对不存的文件进行记录