zoukankan      html  css  js  c++  java
  • Linux下常用命令

    1.批量kill筛选进程

    [root@localhost ~]# ps -ef | grep php-fpm |awk '{print $2}'|xargs kill -9

    2.shell 获取当前日期

    date +%Y 以四位数字格式打印年份
    date +%y 以二位数字格式打印年份
    date +%m 月份
    date +%d 日期
    date +%H 小时
    date +%M 分钟
    date +%S 秒
    date +%w 星期,如果结果显示0,则表示周日

     3.windows下shell脚本在Linux上执行

    dos2unix filename.sh

     4. Linux下查找内容

    find / -type f -name 'go.mod' | xargs grep 'github.com/uber-go/atomic'

    5. 批量停止命令

    supervisorctl status | awk '{if ($1 ~ /^depth*/) print $1}' | xargs supervisorctl stop
    
    sudo supervisorctl status | awk '{if ($1 ~ /okex$/) print $1}' | xargs sudo supervisorctl stop

    6. 批量删除key

    redis-cli keys okex* | xargs redis-cli del

    7. grep命令

    # 打印匹配行的前后10行
    grep -10123’ test.log 
    
    # 打印匹配行的前后10行
    grep -C 10123’ test.log
    
    # 打印匹配行的前后10行
    grep -A 10 -B 10123’ test.log
    
    # 打印匹配行的后10行
    grep -A 10123’ test.log
    
    # 打印匹配行的前10行
    grep -B 10123’ test.log
    
    # 显示既匹配 ‘123’又匹配 ‘456’的行
    grep123’ test.log| grep456’
    
    # 搜索test.log中满足123的内容的行号
    grep -n ‘123’ test.log
    
    # 查看test.log指定行号后的内容,比如50行
    tail -n +50 test.log
    
    # 查看test.log的第50行到100行
    sed -n ‘50,100p’ test.log
  • 相关阅读:
    微服务架构常见解决方案
    摆脱他人的期望,成为真正的自己
    Git忽略提交规则
    JPA多数源的一种方式
    jquery设置的cookie过期时间关闭浏览器就失效
    使用jQuery操作Cookies的实现代码(转)
    Linux下查看文件和文件夹大小
    nginx下默认403 80端口
    linux下 nginx服务脚本
    一串代码在linux上安装nginx
  • 原文地址:https://www.cnblogs.com/yueyun00/p/9897590.html
Copyright © 2011-2022 走看看