User-Profile-Image
hankin
  • 5
  • centos7
  • docker
  • mysql
  • PostgreSQL
  • git/gitlab
  • ELK
  • python
    • python-Tornado
    • python-django
  • redis
  • nginx
  • kvm
  • proxmox
  • mongo
  • kubernetes
  • prometheus
  • GlusterFs
  • nfs
  • freeswitch
  • httpd
  • shell脚本
  • linux
  • fastdfs
  • nextcloud
  • openssl
  • openvpn
  • rabbitmq
  • sqlite
  • svn
  • java
  • ubuntu
  • vue2
  • wordpress
  • php
  • IOT物联网
  • 项目
  • 故障处理
  • 树莓派
  • 博客存档
  • 未分类
  • 杂项
  • #1742(无标题)
  • 新视野
  • 分类
    • 项目
    • 树莓派
    • 杂项
    • 未分类
    • 新视野
    • 故障处理
    • 博客存档
    • wordpress
    • vue2
    • ubuntu
    • svn
    • sqlite
    • shell脚本
    • redis
    • rabbitmq
    • python-django
    • python
    • proxmox
    • prometheus
    • PostgreSQL
    • php
    • openvpn
    • openssl
    • nginx
    • nfs
    • nextcloud
    • mysql
    • mongo
    • linux
    • kvm
    • kubernetes
    • java
    • IOT物联网
    • httpd
    • GlusterFs
    • git/gitlab
    • freeswitch
    • fastdfs
    • ELK
    • docker
    • centos7
  • 页面
    • #1742(无标题)
  • 友链
      请到[后台->主题设置->友情链接]中设置。
Help?

Please contact us on our email for need any support

Support
    首页   ›   shell脚本   ›   正文
shell脚本

linux shell脚本-功能示例

2022-11-04 15:37:29
805  0 0
判断命令是否存在
    which "Command" > /dev/null
    if [ $? -eq 0 ]
    then
    echo command is exist
    else
    echo command not exist
    fi
判断文件存在,判断是否为文件夹等
    testPath="/Volumes/MacBookProHD/Mr.Wen/08 shell命令"  
    testFile="/Volumes/MacBookProHD/Mr.Wen/08 shell命令/fileWen"  

    判断文件夹是否存在 -d    
    if [[ ! -d "$testPath" ]]; then 
     echo "文件夹不存在"  
    else    
     echo "文件夹存在"   
    fi  

    判断文件夹是否存在,并且具有可执行权限 
    if [[ ! -x "$testFile" ]]; then 
     echo "文件不存在并且没有可执行权限"  
    else    
     echo "文件存在并有可执行权限" 
    fi  
判断文件是否存在
    if [[ ! -f "$testFile" ]]; then 
     echo "文件不存在"   
    else    
     echo "文件存在"    
    fi  
一行for循环处理任务
for i in a.txt b.txt c.txt;do echo $i ;done
分析nginx服务日志
cat /var/log/nginx/access.log |awk '{print $1}'|sort|uniq -c |sort -nr| sed 's/[ ]*//'
评论 (0)

点击这里取消回复。

欢迎您 游客  

Copyright © 2025 网站备案号 : 蜀ICP备2022017747号
smarty_hankin 主题. Designed by hankin
主页
页面
  • #1742(无标题)
博主
tang.show
tang.show 管理员
linux、centos、docker 、k8s、mysql等技术相关的总结文档
210 文章 2 评论 194502 浏览
测试
测试