zoukankan      html  css  js  c++  java
  • linux下FIND命令的使用

    Find 的使用
    文件查找
    find .(当前目录) -name
    find . -name "*.txt" -print
    find . -name '[A-Z,a-z,1-100]*'.txt -print
    find . -name "1.txt" -prune -o -name "*.txt" -print
    目录查找
    find . -path"./aa " -prune -o -name "*.txt" -print
    find . -path"./aa " -prune -o -path "./bb" -prune -o -name "*.txt" -print

    权限查找
    find . -prem 775 -print
    不查找aaa下的文件   find . -path "./aa" -prune -0 -perm 775 -print
    find . -path "./aa" -prune -0 -path "./bb" -prune -o -perm 775 -print
    find . ( -path "./aaa" -o -path "./bbb" ) -prune -o -perm 775 -print

    按类型查找

    软连接  可以理解为快捷方式
    ln -s ./aaa/* ./ddd
    find .-type l -print

    按属主查找
    find / -user www -type f -print
    查找属主被删除
    find / -nouser -type f -print

    find / -group apache -type -f -print

    按照时间查找
    两天之内被改过的
    find .-mtime -2 -type f -print
    两天之前被改过的
    find .-mtime +2 -type f -print
    十分钟之前被改过的
    find . -cmin +10 -type f -print

    按照文件新旧查找

    查找比aa.txt新的文件
    find . -newer "aa.txt" -type f -print
    查找比aa.txt旧的文件
    find . ! -newer "aa.txt" -type f -print
    查找比aa.txt新的比bb.txt旧的文件
    find . -newer “aa.txt”! -newer“bb.txt" -type f -print

    按照文件大小查找
    在根目录小大于1M的
    find / -size +1M -type -print
    小于1M的文件
    find / -size -1M -type -print
    执行命令
    find . -name "1.txt" -ok rm {} ;                   新建  touch 12a.txt
    find . -name "12a.txt" -exec cp {}{}.bak ;

    grep 匹配
    cat 1.txt | grep all --color只要出现all   cat 1.txt | grep -w "all" 匹配单词
    cat -n
    取反
     cat 1.txt | grep -v -w "all"
    统计次数
     cat 1.txt | grep -c "all"
    显示行数
    grep -n "all"
    显示匹配的文件
    grep "all"1.txt 2.txt 3.txt
    grep -l "all"1.txt 2.txt 3.txt 只显示匹配出来的文件名

    grep -i "ALL" *.txt  不区分大小写的匹配

    系统服务管理

    chkconfig --list   显示当前运行的所有服务
    /etc/inittab
    netstat -antl   all n端口 t tcp协议 l listen状态
    chkconfig --add httpd 增加服务
    chkconfig --del httpd 删除
    chkconfig --level 12345

  • 相关阅读:
    python struct使用
    pythonunittest(1)
    python os.path模块学习(转)
    pythonunittest(2)
    主机+虚拟机Ubuntu+开发板互相ping通
    wince 外部中断调用可安装ISR错误(data abort)
    wince firstboot.nb0 的大小的问题解决
    wince 串口索引超过10个解决方法
    wince uboot 启动 wince
    zigbee 天线的设计
  • 原文地址:https://www.cnblogs.com/ke-wu/p/5759170.html
Copyright © 2011-2022 走看看