• 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

  • 相关阅读:
    Server2008 Enterprise SP2 is now installed
    “广” && “专”的抉择 个人技术发展之我见!
    从需求到UI的实现策略
    浙江行之杭州
    Windows 7 6956 安装过程感言
    为了生活选择了Microsoft,为了理想仰慕Google
    腾讯2009的一个小BUG,发现腾讯竟然也在用nginx
    生活GOOGLE,GOOGLE生活
    整理下自己电脑所用的软件下一步一步一步走做好该做的
    面试的一天二天
  • 原文地址:https://www.cnblogs.com/mangojun/p/11368955.html
Copyright © 2020-2023  润新知