`
chenchao051
  • 浏览: 135909 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

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

阅读更多
#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



分享到:
评论

相关推荐

    Java 调用 Linux shell 命令执行框架:sshxcute

    sshxcute 就是这样一个框架工具集,它基于 JSCH 构建,允许工程师利用Java 代码通过 SSH 连接远程批量执行 Linux/UNIX 系统上的命令或者脚本,同时加入了判断成功与否,取回输出等多种实用功能。sshxcute 不管是针对...

    入门学习Linux常用必会60个命令实例详解doc/txt

    immortality按:请用ctrl+f在本页中查找某一部分的内容或某一命令的用法。 -------------------------------------------------------------------------------- Linux必学的60个命令(1)-安装与登陆命令 login 1...

    linux最实用的命令集 和 工具

    包括 linux如何查看环境变量.txt sed修改文件内容 Shell脚本:判断文件、文件夹是否存在.txt sshpass的使用方法.txt vi 文件编辑 查看xshell保存的密码.txt 防火墙.txt 等 很有价值的内容。新老手都适用哦!!!

    linux最实用的命令集 和 工具 记载

    包括 linux如何查看环境变量.txt sed修改文件内容 Shell脚本:判断文件、文件夹是否存在.txt sshpass的使用方法.txt vi 文件编辑 查看xshell保存的密码.txt 防火墙.txt 等 很有价值的内容。新老手都适用哦!!!

    Excel VBA实用技巧大全 附书源码

    04142设置单元格字符串中一部分字符的格式(其他字体属性) 04143设置单元格的下画线 04144设置单元格的字体属性(字体、字号、加粗、斜体、颜色等) 04145设置单元格区域的外部边框 04146设置单元格区域的全部边框 ...

    大量批处理实用程序例程

    本资源由大量的实用批处理文件组成,删除.txt尾缀名双击即可直接使用,既是学习的模板也可以作为实用程序,如下为文件组成,涉及文件管理,系统,网络,小工具等等: 0-reaname 2000XP停止打印.bat BAT珍藏 dir.bat...

    NSIS用户手册(中文版)

    条件编译 !define !undef !ifdef !ifndef !if !ifmacrodef !ifmacrondef !else !endif !insertmacro !macro !macroend !searchparse !searchreplace 附录 A: 新式用户界面(Modern UI) 附录 B: DLL/...

    Linux学习Shell Scripts(脚本)

    声明: Shell Scripts是个自动管理系统软件的...1.1 shell script其实就是一个文档(里面包含很多的命令,有简单的格式,一行一行的执行),可以直接用vim编辑(vim很适合写脚本哦)。 现在我们假设你写的这个程序文件

    VB编程常用的几个技巧

    在 VB 中,我们可以使用 Shell 函数来执行系统命令,例如强制关机命令。下面的代码将在 300 秒后强制关机: Private Sub Command1_Click() Shell "shutdown -s -t 300" End Sub 在上面的代码中,shutdown 是系统...

    网吧维护技术资料 合集

    3331 网吧维护\资料\xp实用技巧\破解Windows XP中WPA的武器现身.txt 3055 网吧维护\资料\xp实用技巧\硬件不兼容的处理.txt 5273 网吧维护\资料\xp实用技巧\系统和磁盘操作命令.txt 675 网吧维护\资料\xp实用技巧\...

    ubuntu:适用于软件开发人员的Ubuntu安装脚本!!!!

    该项目是一个安装脚本,它允许在一个命令中安装编程语言,二进制文件和实用程序! 支持的操作系统 的Ubuntu Linux Mint 安装 以下示例显示如何使用安装脚本: curl -s ' ...

    网管教程 从入门到精通软件篇.txt

    小编的确一直都想把这方面的命令做个总结,这次辛苦老范给我们整理了这份实用的秘笈。  Bootcfg  bootcfg 命令启动配置和故障恢复(对于大多数计算机,即 boot.ini 文件)。  含有下列参数的 bootcfg 命令仅在...

    易语言700模块打包

    操作其它程序中的超级列表框1.0(1.0).zip 查找窗口内所有组件句柄(1.0).zip 查杀程序(1.0).zip 磁盘操作(1.0).zip 超级列表快速排序(2.0).zip 超级列表框补丁1.0(1.0).zip 传奇世界登陆模块(1.9).zip 磁性...

    易语言模块大全(共775个模块)

    操作其它程序中的超级列表框1.0(1.0).zip 查找窗口内所有组件句柄(1.0).zip 查杀程序(1.0).zip 磁盘操作(1.0).zip 超级列表快速排序(2.0).zip 超级列表框补丁1.0(1.0).zip 传奇世界登陆模块(1.9).zip 磁性窗口模块V...

    JAVA上百实例源码以及开源项目

     用JAVA开发的一个小型的目录监视系统,系统会每5秒自动扫描一次需要监视的目录,可以用来监视目录中文件大小及文件增减数目的变化。 Java日期选择控件完整源代码 14个目标文件 内容索引:JAVA源码,系统相关,日历,...

    JAVA上百实例源码以及开源项目源代码

     用JAVA开发的一个小型的目录监视系统,系统会每5秒自动扫描一次需要监视的目录,可以用来监视目录中文件大小及文件增减数目的变化。 Java日期选择控件完整源代码 14个目标文件 内容索引:JAVA源码,系统相关,日历,...

Global site tag (gtag.js) - Google Analytics