zoukankan      html  css  js  c++  java
  • shellscript 02 find & xargs

    再谈 find 命令

    find pathname –options [-print –exec –ok ]

    pathname : 目录

    - print : 将匹配的文件输出到标准输出

    - exec : 对匹配的文件执行该参数所给出的 shell 命令. 命令参数为 ‘command’ {} \; 注意 {} 和 \ ; 之间的空格

    - ok     : 和 –exec 作用相同,只不过以一种更为安全的模式来执行该参数的 shell 命令,在每次执行之前,都会给出提示,让用户来确定是否执行。

    find 命令选项

    -name : 按照文件名查找

    -perm : 按照文件权限查找

    -prune : 不在当前目录中查找

    -user : 按照文件属主来查找文件

    -group : 按照组来查找

    -mtime –n +n 按照文件被修改时间, 开可以按照 –atime, –ctime

    -nogroup 查找不在 /etc/groups 中不存在

    -nawer file1 ! file2 查找更改时间比文件 file1 新 但比文件 file2 旧的文件。

    -type 查找某一类型文件 ( b 快设备文件,d 目录,c 字符设备文件,p 管道文件,l 符号链接文件,f 普通文件 )

    -depth : 首先查找当前目录中的文件,然后再在其字目录中查找。

    -mount : 查找不跨越文件系统 mount 点

    -follow : 如果 find 命令遇到符号链接文件,就跟踪至链接所指向的文件。

    -cpio : 对匹配的文件使用 cpio 命令,将这些文件备份到设备中。

    例子 :

    find ~ –name “*.txt”-print

    find . –name “[a-z][a-z][0-9][0-9].txt” –print

    find . –perm 755 –print ( find . –perm –007 –print )

    find /apps –name “/apps/bin” –prune –o –print

    find ~ –user dave –print         find ~ –nouser –print

    find ~ –group accts –print       find / –nogroup –print

    xargs

    find 命令和 xargs 命令的用处所在。

    find . –name “core” –print | xargs echo “” > /tmp/core.log

  • 相关阅读:
    基本的Web控件二
    基本的Web控件一
    centos更改默认语言
    nginx优化配置
    使用nginx的proxy_cache做网站缓存
    centos7配置笔记
    redis批量删除
    Linq常用操作
    MVC ViewData和ViewBag[转]
    Transact-SQL的除法问题
  • 原文地址:https://www.cnblogs.com/moveofgod/p/2819001.html
Copyright © 2011-2022 走看看