linux shell命令中cp时判断文件夹是否存在解决cannot create regular file ‘…’: No such file or directory
直接使用cp命令时,如果新的路径不存在则会报错cannot create regular file ‘…’: No such file or directory所以要先判断文件夹是否存在,然后再使用cp复制文件并且判断新文件夹是否存在,不存在则新建文件夹再复制#!/bin/bash#获取新路径的文件夹path=$(dirname $2)#判断将新路径的文件夹是否存在if [ ! -d "${path}" ]; thenecho "创建目录:${path}"mkdir -p "${path
原创
2020-07-04 11:14:04 ·
11693 阅读 ·
0 评论