Is there anyway to copy a file to a directory that does not exist?
我想通过让
所以这是一个例子,我的桌面上有一个名为
1 | cp temp.file ./createThisFolder/ |
我查看了手册页,没有看到任何内容。 我想这样做的原因是因为我想稍后在该目录上运行测试。 如果目录不存在,我知道没有文件在等我。
在复制之前,您需要执行
如果你想知道目录中是否有文件,我建议直接检查你的文件是否存在(而不是检查目录是否存在)。 例如:
1 2 3 | if [ ! -s ./createThisFolder/temp.file ] ; then echo"file doesn't exist (or it is empty)" fi |