zoukankan      html  css  js  c++  java
  • linux shell 命令笔记

    标准输入、标准输出、标准错误

    File descriptors are integers associated with an opened file or data stream. File descriptors 0,
    1, and 2 are reserved as follows:
     0 –  stdin (standard input)
    1 –  stdout (standard output)
    2 –  stderr (standard error)

    重定向(默认只重定向标准输出)  > 覆盖重写 >> 添加

    重定向标准错误和标准输出到不同文件  cmd 2>stderr.txt 1>stdout.txt

    重定向到同一个文件 cmd 2>&1 out.txt

    不输出标准错误 cmd 2>/dev/null

    管道命令(|)

    find 命令

    find ../ test.txt 

    find -name "*.txt"

    find . -iname "example*" -print  忽略大小写查找

    find . ( -name "*.txt" -o -name "*.pdf" ) -print  多条件查找

    find /home/users -path "*slynux*" -print  查找目录

    find . -regex ".*(.py|.sh)$"       正则表达式查找

    find . ! -name "*.txt" -print    查找不是以.txt结尾的文件

    find . -type d -print 查找目录

    根据时间做查找

    find . -type f -atime -7 -print    查找7天内访问过的文件

    find . -type f -mtime -7 -print    查找7天内修改过的文件

    find . -type f -ctime -7 -print    查找7天内修改过权限或者拥有者的文件

    以下三个选项对应的是分钟

    -amin (access time)
    f -mmin (modification time)
    f -cmin (change time)

    find . -type f -newer file.txt -print   查找修改时间比file.txt早的文件

    根据文件大小做查找

    b – 512 byte blocks
    c – bytes
     w – two byte words
     k – Kilobyte
     M – Megabyte
    G – Gigabyte

    find . -type f -size +2k  查找大于2k的文件

    find . -type f -size -2k  查找小于2k的文件

    find . -type f -size 2k  查找等于2k的文件

    File type       Type argument
    Regular file       f
    Symbolic link    l
    Directory          d
    Character special device c
    Block device    b
    Socket             s
    Fifo                  p

    find . -type f -name "*.swp" -delete  找到文件的同时删除

     find . -type f -atime -7  | xargs  ls -lt 2>>/dev/null | head -n 1  查找七天内访问过的最近一条文件记录
    ls -lrt  时间升序排列

    ls -lt   时间降序排列

    删除某个进程

    ps -aux | grep 'python' | awk '{print $2}' | xargx kill

  • 相关阅读:
    Angularjs 设置全局变量的3种方法
    prevent to do sth 与 prevent sb (from) doing 用法
    软件测试技术对程序员的重要性
    Javascript中setTimeout()以及clearTimeout( )的使用
    Javascript异步编程的常用方法
    软件设计原则总结
    为sublime Text3 安装插件JS Format
    javascript中 if(变量)和if(变量==true)的区别
    Ping 命令
    ipconfig
  • 原文地址:https://www.cnblogs.com/mangojun/p/11368955.html
Copyright © 2011-2022 走看看