bash - running command in loop by properties file Shell script -
i want run git command to create new branch, command is:
git checkout -b branch1.00 branch1.00
now want run command when instead of "branch1.00" have parameter (lets call $branch) , parameter take it's value .properties file (lets call file prop.properties) , run command on values in file.
so if prop.properties file that:
branch=branch1.00 branch=branch2.00 branch=branch3.00 branch=branch4.00
the git command run 4 times that:
git checkout -b branch1.00 branch1.00 git checkout -b branch2.00 branch2.00 git checkout -b branch3.00 branch3.00 git checkout -b branch4.00 branch4.00
any idea how that?
this while
loop job:
while ifs='=' read -r _ b; git checkout -b "$b" "$b" done < prop.properties
if there no branch=
prefix use:
while read -r b; git checkout -b "$b" "$b" done < prop.properties
this run these commands:
git checkout -b branch1.00 branch1.00 git checkout -b branch2.00 branch2.00 git checkout -b branch3.00 branch3.00 git checkout -b branch4.00 branch4.00
Comments
Post a Comment