首页 > 系统相关 >bash shell notes:

bash shell notes:

时间:2023-04-19 19:04:44浏览次数:43  
标签:tmp bin shell tempfile notes file bash


#!/bin/bash
config_file='xxxxx'
tmp_file=/tmp/tempfile.$$



function usage()
{
cat <<!
usage: $(basename $0) options

options
aaa       switch to aaa
bbb       switch to bbb
ccc       switch to ccc
!
    exit 9
}

cmd=$1

if [ $# -eq 0 ]; then 
echo Required parameter '"'Environment'"' not set 
exit 1
usage 
fi 


if [ "$cmd" = "aaa" ]; then 
  cd ~/test/aaa/
  cp $config_file $tmp_file

  url="xxxxxxxxxxxxxx"
  sed -i -e s/xxxxxxxxxx=.*/$url/ $tmp_file
  cp $tmp_file $config_file
fi


  
if [ "$cmd" = "bbb" ]; then
  cd ~/test/bbb/
  cp $config_file $tmp_file

  sed -i -e "s/shouldLogSql = System.properties.containsKey(\"logSql\")/shouldLogSql = true/" $tmp_file

  cp $tmp_file $config_file
fi

if [ "$cmd" = "ccc" ]; then
  cd ~/test/ccc/
  cp $config_file $tmp_file

  if grep "getEnvironment()\.toLowerCase()" $tmp_file; then
    sed -i -e "s/getEnvironment()\.toLowerCase()/\"apac\"/" $tmp_file
  fi

  cp $tmp_file $config_file
fi

 

标签:tmp,bin,shell,tempfile,notes,file,bash
From: https://blog.51cto.com/u_6174294/6207215

相关文章

  • Shell多线程备份数据库
    Shell这么简单的脚本语言有多线程这一说吗?答案是有的。只不过它实现起来稍微有点难理解罢了,因为它借助了命名管道实现。所谓多线程就是原本由一个进程完成的事情现在由多个线程去完成。假如一个进程需要10小时完成的事情,现在分配10个线程,给他们分工,然后同时去做这件事情,最终可能就......
  • some useful notes for cygwin
    usefulaliaslist:==================aliasgrep='grep--color'aliasl.='ls-d.*--color=tty'aliasla='ls-la'aliasll='ls-l'aliaslr='ls-lrt'aliasls='ls--color=auto'aliaswhich='......
  • call bash shell script by dos command
     1.atfirstwehaveascriptsaytest.sh 2.tocallitweneedabashshellenvironmentinwindows,saycygwin 3.thenrunbelowcommand: C:\XXXX\Cygwin\bin\bash--login"/cygdrive/e/scripts/test.sh"  that'sit. ......
  • 如何处理 bash shell 变量中的斜杠(/)?
    #!/bin/bash##Ourpath_r1="/nfs/apache/logs/rawlogs/access.log"##Escapepathforsedusingbashfindandreplace_r1="${_r1//\//\\/}"#replace__DOMAIN_LOG_FILE__inoursample.awstats.confsed-e"s/__DOMAIN_LOG_FILE......
  • Windows 上的 Bash 正在成为微软的 Linux
    微软对WindowsSubsystemfor Linux(WSL)的一系列大量更新被列入WindowsInsiderbuild15002,该版本已于1月10日开始推送给Windows10用户。微软的WSL计划仍然是具有较强的暂时性和实验性的,但该公司正在不断往上添加功能,以飞快的步伐改进和扩展WSL。这在一定程度上......
  • Windows 上的 Bash 正在成为微软的 Linux
    微软对WindowsSubsystemfor Linux(WSL)的一系列大量更新被列入WindowsInsiderbuild15002,该版本已于1月10日开始推送给Windows10用户。微软的WSL计划仍然是具有较强的暂时性和实验性的,但该公司正在不断往上添加功能,以飞快的步伐改进和扩展WSL。这在一定程度上......
  • Windows 上的 Bash 正在成为微软的 Linux
    微软对WindowsSubsystemfor Linux(WSL)的一系列大量更新被列入WindowsInsiderbuild15002,该版本已于1月10日开始推送给Windows10用户。微软的WSL计划仍然是具有较强的暂时性和实验性的,但该公司正在不断往上添加功能,以飞快的步伐改进和扩展WSL。这在一定程度上......
  • 四月学习之LVS shell脚本配置DR模型
    1、DS脚本配置#!/usr/bin/bashVIP=172.16.1.100RS1=172.16.1.5RS2=172.16.1.6PORT=80SCHEDULER=rrDEV=eth1:1case$1instart)#配置虚拟IP地址VIP cat>/etc/sysconfig/network-scripts/ifcfg-${DEV}<<-EOF TYPE=Ethernet BOOTPROTO=none DEFROUTE=y......
  • Python + Shell 巡检服务器
    1.背景团队维护多套业务系统,有支付系统、金融系统、数据系统、核验系统等二十多套业务系统,每套业务系统有10-50台服务器不等,当前团队中存在一套自动化巡检系统,每十分钟巡检一次,有异常可实时告警。但每天还需要人工登录服务器巡检两次,因人工巡检耗时长、漏巡风险大,需要一个运维巡......
  • Shell脚本--case in
    当分支较多,并且判断条件比较简单时,使用casein语句就比较方便了。其基本格式为:caseexpressioninpattern1)statement1;;pattern2)statement2;;pattern3)statement3;;……*)statem......