shell 常用脚本命令

本文主要记录日常工作中使用到的shell命令,简单记录一下

  1. getopts
    脚本可以获取指定输入参数,然后根据不同参数执行不同逻辑
    例子: bash start.sh -a 10 -b test
  2. sed
    替换文件中指定值
    例子:把es_hosts替换成ES_HOSTS变量
    sed -i "s/es_hosts/$ES_HOSTS/g" /home/es/config/es.yml
  3. tr
    转换字符、删除字符和压缩重复的字符
    例子:输出为a b c
    test=a,b,c
    echo $test | tr ',' ' '

你可能感兴趣的:(shell 常用脚本命令)