I have a git repo of configuration files segregated by branches, e.g.:
refs/heads/branch1, file - settings.properties
refs/heads/branch2, file - settings.properties
etc.
I'm trying to grep certain property of every each of the settings.properties
file in every each of the repository:
git for-each-ref refs/heads --shell --format=‘%(refname:short)’ | xargs -n1 git checkout | cat settings.properties | grep ‘host.name’
The first command gives me the list of my branches, the second one checks me out to every branch one after another and I expect 3rd command cat the file and 4th to grep certain property. First 2 commands work just fine but if I run the whole thing it just greps host.name only for the first branch.
I'm obviously missing something essential about the pipelines. I know I can write it as a shell script and do all this in a loop, but I would like to keep the 'pipeline' approach, because I may often need to cat
different files and grep
different properties and wouldn't want to deal with passing parameters into the script