Posts tagged with “script”

switch case in bash script

, change the first letter of the value of the variable to lowercase, ,, change the value of the whole variable to lower case.

$ test='HELLO'
$ echo $test
HELLO
$ echo ${test,}
hELLO
$ echo ${test,,}
hello
$ test=${test,,}
$ echo ${test^}
Hello
$ echo ${test^^}
HELLO

A bash script to keep two git branch identical.

#!/bin/bash

git push
currentbranch=`git branch --show-current`
if [ "${currentbranch}" == "local" ]; then
   git checkout develop
   git merge local
   git push
elif [ "${currentbranch}" == "develop" ]; then
   git checkout local
   git merge develop
   git push
fi
git checkout $currentbranch

Don't ask why I wrote this foolish script. I have to do it 😀