zoukankan      html  css  js  c++  java
  • Linux-命令-基本-find-exec

    命令: find <path> [option]

    参数:

    path: 注意 find folder1/* -type d   和 find folder1/ -type d  不同,  folder1/ 后如果没有*号,folder 1也会出现在被查找范围内.如果执行删除命令时,folder1会被删除掉.

    -maxdepth : 查询深度,e.g. find . -maxdepth 1 -type d 只查询当前目录下的文件夹目录.

    -type: f 文件 d 目录

    -name: 文件或目录名

    -a: 交集 and  e.g. [root@ark log]# find . -type f -name yum.log -o -name 'bt*'

    -o: 并集 or

    -exec: 对查找到的结果执行什么动作.

        e.g.  find . -type f -name 'abc.txt' -exec {} ;   {} 代表前面所找到的内容

        e.g.  find . -type f -name ' *.txt' | xargs rm -f   *为通配符

            使用*作为通配符,如find结果为 a.txt b.txt

            使用管道向 rm 专递找到的结果,使用xargs 做为一行进行删除,等于 rm -f a.txt b.txt

            

    -------------------- 阑心而慧智,心静而致远. --------------------
  • 相关阅读:
    java ppt4
    课后作业 2
    课后作业2
    java ppt题目
    CommandParameter设计
    《大道至简》第二章读后感
    8.多态
    7.接口与继承
    6.数组
    字符串
  • 原文地址:https://www.cnblogs.com/mirrorlake/p/7336997.html
Copyright © 2011-2022 走看看