I am writing a bash function to get all the git repositories, but I ran into a problem when I want to save all the paths to the git repository for the patharray array. Here is the code:
gitrepo() { local opt declare -a patharray locate -b '\.git' | \ while read pathname do pathname="$(dirname ${pathname})" if [[ "${pathname}" != *.* ]]; then
I want to save all the repository paths to the patharray array, but I cannot get it outside the pipeline , which consists of the locate and while command.
But I can get the array in the pipeline command, the commented command # echo -e ${patharray[@]} works well if it is not ready, so how can I solve the problem?
And I tried the export command, however it seems that it cannot pass patharray to the pipeline.
arrays bash pipeline
zhenguoli May 14 '16 at 16:19 2016-05-14 16:19
source share