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

  • 相关阅读:
    configure: error: no acceptable cc found in $PATH
    SQL server的错误日志导致服务器C盘满
    域名/IP 正则表达式
    rpm 基本命令
    VB TO C#
    yum 的基本操作
    在服务器上怎么检查一个网站的在线连接数有多大。
    MSSQL2005不能连接远程有非法字符密码的数据库
    按账目类型和日期查看账目
    梦断代码读书笔记(二)
  • 原文地址:https://www.cnblogs.com/ke-wu/p/5759170.html
Copyright © 2011-2022 走看看