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

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -