Skip to content

Instantly share code, notes, and snippets.

@andyr
Created September 22, 2012 18:08
Show Gist options
  • Save andyr/3767256 to your computer and use it in GitHub Desktop.
Save andyr/3767256 to your computer and use it in GitHub Desktop.
Print paths to all git repos in a directory tree.
#!/bin/sh
ls -lRA | grep "\.git:$" | sed 's/\.git://g'
@andyr
Copy link
Author

andyr commented Sep 22, 2012

Currently, this command doesn't format the output as the top level repo directory only, but has parens around the regexp used in the awk statement to try and handle this last bit. I'm somewhat new to awk, so I left it as-is for the moment since it solves my problem of finding a bunch of disparate git repos in my home directory. The output of this command would look like the following.

./node.js/.git
./raspberrypi/quake3/.git

@andyr
Copy link
Author

andyr commented Sep 28, 2012

The output of the replaced command above properly produces the desired output (removes the trailing ".git" from the dir listing):

$ ls -lRA | grep "\.git:$" | sed 's/\.git://g'
./raspberrypi/firmware/
./raspberrypi/linux/
./raspberrypi/quake3/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment