shell中的判断条件及部分实用命令

编程技术  /  houtizong 发布于 3年前   99
#String Comparison Operators
   Operator                      True if...
str1 = str2a                str1 matches str2
str1 != str2                str1 does not match str2
str1 < str2                 str1 is less than str2
str1 > str2                 str1 is greater than str2
-n str1                     str1 is not null (has length greater than 0)
-z str1                     str1 is null (has length 0)


#File Attribute Operators
   Operator                      True if...
    -d file                 file exists and is a directory
    -e file                 file exists
    -f file                 file exists and is a regular file (i.e.,  not a directory or other special type of file)
    -r file                 You have read permission on file
    -s file                 file exists and is not empty
    -w file                 You have write permission on file
    -x file                 You have execute permission on file, or directory search permission if it is a directory
    -O file                 You own file
    -G file                 file's group ID matches yours (or one of yours, if you are in multiple groups).
    file1 -nt file2         file1 is newer than file2
    file1 -ot file2         file1 is older than file2

#Arithmetic Test Operators
      Test                      Comparison
     -lt                    Less than
     -le                    Less than or equal
     -eq                    Equal
     -ge                    Greater than or equal
     -gt                    Greater than
     -ne                    Not equal

判断某文件的修改时间:
stat 文件 | grep Modify | awk '{print $2}'

查看时间:
date +%F = date +%Y-%m-%d 
date +'%F %T' = date +'%Y-%m-%d %H:%M:%S'

根据进程名字找到pid:
ps -ef | grep 'HRegionServer' | grep -v 'grep' | awk '{print $2}'

远程根据进程名杀死进程
pid=`ssh server3 ps -ef | grep 'HRegionServer' | grep -v 'grep' | awk '{print $2}'`
ssh server3 kill -9 $pid

改ip
sudo ifconfig eth0:0 192.168.244.128 broadcast 192.168.244.255 netmask 255.255.255.0 up



请勿发布不友善或者负能量的内容。与人为善,比聪明更重要!

留言需要登陆哦

技术博客集 - 网站简介:
前后端技术:
后端基于Hyperf2.1框架开发,前端使用Bootstrap可视化布局系统生成

网站主要作用:
1.编程技术分享及讨论交流,内置聊天系统;
2.测试交流框架问题,比如:Hyperf、Laravel、TP、beego;
3.本站数据是基于大数据采集等爬虫技术为基础助力分享知识,如有侵权请发邮件到站长邮箱,站长会尽快处理;
4.站长邮箱:[email protected];

      订阅博客周刊 去订阅

文章归档

文章标签

友情链接

Auther ·HouTiZong
侯体宗的博客
© 2020 zongscan.com
版权所有ICP证 : 粤ICP备20027696号
PHP交流群 也可以扫右边的二维码
侯体宗的博客