I was trying to build a quick script to find all the git repos under a directory and sequentially "git pull" each one.
This is what I found so far:
find ~/ -name ".git" -type d | sed 's,/*[^/]\+/*$,,' | xargs -L1 bash -c 'cd "$1" && git pull' _
If pasted into a terminal, this will work exactly as it's intended. However, if I make this into an alias in my .bashrc
file:
alias gpa="find ~/ -name ".git" -type d | sed 's,/*[^/]\+/*$,,' | xargs -L1 bash -c 'cd "$1" && git pull' _"
The command doesn't work. I modified it in an attempt to get it to print what the subshell launched by xargs is receiving:
alias printgpa="find ~/ -name ".git" -type d | sed 's,/*[^/]\+/*$,,' | xargs -L1 bash -c 'echo "$1"' _"
When run, each subshell prints a newline, but nothing else.
Can anyone answer why this is happening? My gut feeling says that it's a problem with my syntax in the alias, but I don't know exactly what's going on.