zoukankan      html  css  js  c++  java
  • 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 . -name test.txt

    在当前目录下模糊搜索文件:

    find . -name '*.txt'

    目录查找
    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

  • 相关阅读:
    vi—终端中的编辑器
    CSS Selector
    转: 通过WMI获取网卡MAC地址、硬盘序列号、主板序列号、CPU ID、BIOS序列号
    WMI入门教程之WMI中的类在哪里?
    WMI测试器
    WMI Explorer操作 和 powershell命令
    C++ WMI获取系统硬件信息(CPU/DISK/NetWork etc)
    使用C++进行WMI查询的简单封装
    ubuntu版本信息查看
    win10 修改文件夹右击默认打开程序
  • 原文地址:https://www.cnblogs.com/debruyne/p/9283012.html
Copyright © 2011-2022 走看看