这是我正在处理的目录的内容:

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 错误处理的更多相关文章

  1. /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 ...

  2. 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 ...

  3. mkdir()提示No such file or directory错误的解决方法

    转自:http://www.02405.com/program/php/1692.html 在php中使用mkdir()方法创建文件夹时报错:No such file or directory,出错代 ...

  4. Linux运行shell脚本提示No such file or directory错误的解决办法

    Linux执行.sh文件,提示No such file or directory的问题: 原因:在windows中写好shell脚本测试正常,但是上传到 Linux 上以脚本方式运行命令时提示No s ...

  5. 解决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 ...

  6. mingw32-g++.exe: *: No such file or directory错误解决方法

    初次使用CodeBlocks,好不容易把环境配好, 编译没有错误了,但是程序并不生成exe,提示以下问题: mingw32-g++.exe: /W3: No such file or director ...

  7. 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 ...

  8. 向CodeBlocks的Project中添加calss文件时,出现No such file or directory错误的解决方案

    我们在CodeBlocks中编写程序时,一般要建立工程.现在建立工程first,然后建立类文件Person,并将其添加到first中, int main() { Person p; p.display ...

  9. Popen No such file or directory 错误

    File , in reload_config stderr=PIPE, env={"PATH": '', "HOME": "/root"} ...

随机推荐

  1. AT2163 [AGC006B] Median Pyramid Easy

    需要一点灵感的题目. 可以发现这样一个事情,当三个数中有两个数相同时,中为数一定是这两个相同的数. 基于这个观察,我们想让每一行都存在这样两个相同的两个数,就一定能保证第一层的值为 \(x\) 了. ...

  2. asp.net core 中的各种路径

    1.获取完整网址URL 方法一:先引用"using Microsoft.AspNetCore.Http.Extensions;",然后直接用"Request.GetDis ...

  3. linux centos6.3 升级svn1.6到svn1.8

    linux centos6.3 升级svn1.6 1. 删除svn1.6 #yum remover subverson12.设置svn1.8安装源 vim /etc/yum.repos.d/wandi ...

  4. Java8-Consumer、Supplier、Predicate和Function方法总结

    这几个接口都在 java.util.function 包下的,分别是Consumer(消费型).supplier(供给型).predicate(谓词型).function(功能性): 那么,下面,我们 ...

  5. svn 用户名,密码 查看/删除

    1.查看svn 的用户名,密码: 找到用户名,密码文件,都是明文的,你可以看到 例:linux ls ~/.subversion/auth/svn.simple 2ab598e9cb6d6d38761 ...

  6. 如何使PreparedStatement支持命名参数

    http://m.blog.csdn.net/wallimn/article/details/3734242

  7. 【HDU6662】Acesrc and Travel(树型Dp)

    题目链接 大意 给出一颗树,每个点上有一个权值\(A[i]\),有两个绝顶聪明的人甲和乙. 甲乙两人一起在树上轮流走,不能走之前经过的点.(甲乙时刻在一起) 甲先手,并可以确定起点.甲想要走过的点权之 ...

  8. 学多少年才算“精通Java”?

    我从毕业做程序员就开始用 Java,到现在已经工作快 20 年了.减去我做手游用 C++.Lua 的几年,再减去后来转管理写代码少的时间,我真正写 Java 代码的时间至少也在 10 年以上. 如果你 ...

  9. 使用jvisualvm监控k8s内java项目

    资源文件yaml配置 -javaagent:/usr/skywalking/agent/skywalking-agent.jar -Dcom.sun.management.jmxremote -Dja ...

  10. Bugku--web-wp

    Bugku地址:https://ctf.bugku.com/challenges 0x01 web2 地址:http://123.206.87.240:8002/web2/ ,查看源码 web2 0x ...