find: `./folder': No such file or directory 错误处理
这是我正在处理的目录的内容:
misha@hp-laptop:~/work/c/5$ ls -l
total 8
-rw-rw-r-- 1 misha misha 219 May 20 15:37 demo.c
drwxrwxr-x 2 misha misha 4096 May 20 16:07 folder
-rw-rw-r-- 1 misha misha 0 May 20 16:06 test
现在,我想从这个目录中删除文件之外的所有内容。demo.c
..下面是我想出的命令:
find . ! \( -name demo.c -o -name . \) -exec rm -Rf {} \;
它所做的和你想要做的完全一样(意思是,文件test
和目录folder
),但同时也会显示以下错误消息:
find: `./folder': No such file or directory
因为find
认./folder
作为一个目录,当它第一次读取目录时.
,在考虑它是否与find
标准或对其执行任何行动。它不知道该操作将删除该目录,因此在执行该操作后,它将尝试下降到该目录以扫描其内容。但是,当它这样做时,目录就不再存在了。
有多种方法来解决这个问题。还没有提到的是使用-prune
行动。这说明find
不进入与测试匹配的目录:
find . ! \( -name demo.c -o -name . \) -exec rm -Rf {} \; -prune
find: `./folder': No such file or directory 错误处理的更多相关文章
- /etc/rc.d/init.d/iptables: No such file or directory 错误原因
注:本文转载自cnblogs:一天学点的文章</etc/rc.d/init.d/iptables: No such file or directory 错误原因> RedHat Enter ...
- php的mysqli_connect函数显示 No such file or directory错误以及localhost换成127.0.0.1执行成功
Centos7环境-php7-MariaDB5.5.60 (新安装的php7,执行php -m 显示有mysqli模块,php.ini没有改其它) 测试代码为: <?php //~ echo d ...
- mkdir()提示No such file or directory错误的解决方法
转自:http://www.02405.com/program/php/1692.html 在php中使用mkdir()方法创建文件夹时报错:No such file or directory,出错代 ...
- Linux运行shell脚本提示No such file or directory错误的解决办法
Linux执行.sh文件,提示No such file or directory的问题: 原因:在windows中写好shell脚本测试正常,但是上传到 Linux 上以脚本方式运行命令时提示No s ...
- 解决openssl: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory错误
问题 在Centos7上编译安装openssl后,运行openssl version出现如下错误: openssl: error while loading shared libraries: lib ...
- mingw32-g++.exe: *: No such file or directory错误解决方法
初次使用CodeBlocks,好不容易把环境配好, 编译没有错误了,但是程序并不生成exe,提示以下问题: mingw32-g++.exe: /W3: No such file or director ...
- linux e2fsprogs安装解决uuid/uuid.h: No such file or directory错误
linux查看某个包是否安装 dpkg -l libuu* 用gcc编译发生nux 错误:fatal error: uuid/uuid.h: No such file or directo ...
- 向CodeBlocks的Project中添加calss文件时,出现No such file or directory错误的解决方案
我们在CodeBlocks中编写程序时,一般要建立工程.现在建立工程first,然后建立类文件Person,并将其添加到first中, int main() { Person p; p.display ...
- Popen No such file or directory 错误
File , in reload_config stderr=PIPE, env={"PATH": '', "HOME": "/root"} ...
随机推荐
- 300iq Contest 1 C Cool Pairs
为了构造时恰好取到 \(k\) 对时的方便,可以考虑将 \(a\) 设为互不相同的 \(n\) 个数,这样对每个 \(b\) 的取值对答案的贡献就是可以通过调整变成任意值的. 因为要尽可能造成贡献,因 ...
- Spring service本类中方法互相调用事物失效问题
简介 Spring事物利用的是AOP,动态代理采用CGLIB代理(默认,也可以用Proxy代理,但是Proxy代理效率低于CGLIB代理).故只要弄懂Spring的AOP实现,就知道为什么servic ...
- SpringBoot前后端数组交互
前端 后端 Gitee地址 https://gitee.com/zhuayng/foundation-study.git 参考 https://blog.csdn.net/qq_34091758/ar ...
- Entity Framework 在OrderBy排序中使用字符串
public static class LinqExtensions { private static PropertyInfo GetPropertyInfo(Type objType, strin ...
- 入门-k8s部署应用 (三)
Kubernetes 部署应用 在 k8s 上进行部署前,首先需要了解一个基本概念 Deployment Deployment 译名为 部署.在k8s中,通过发布 Deployment,可以创建应用程 ...
- Web标准和骨架
Web 标准的好处 1.让Web的发展前景更广阔 2.内容能被更广泛的设备访问 3.更容易被搜寻引擎搜索 4.降低网站流量费用 5.使网站更易于维护 6.提高页面浏览速度 Web 标准构成 Web标准 ...
- 有关 iOS 的开发证书、应用标识、设备标识、配置文件以及密钥 #DF
iOS开发过程中如果需要进行真机调试.发布需要注册申请很多证书, 以下是对iOS开发的常用证书和密钥等的逐一简单说明: 证书 iOS常用的证书包括开发证书和发布证书,无论是真机调试还是最终发布应用到A ...
- iOS,蓝牙开发!!--By帮雷
iOS的蓝牙开发大致有以下几种方式. 1 GameKit.framework [只能存在于iOS设备之间,多用于游戏 能搜索到的demo比较多,不确切说名字了,code4app里面就有] 2 Core ...
- Solution -「多校联训」数学考试
\(\mathcal{Description}\) Link. 给定 \(n\) 个函数,第 \(i\) 个有 \(f_i(x)=a_ix^3+b_ix^2+cx_i+d~(x\in[l_i, ...
- Spring容器变化之SmartLifecycle,LifecycleProcesso接口详述
Spring Boot run方法启动后相应的服务也随之启动,这个操作很妙.使用者都不用关心什么服务怎么启动,不管多少个服务怎么启动只要符合Spring Boot的启动规则都可以使用其run方法同一启 ...