Created
December 12, 2010 14:26
-
-
Save itayd/738076 to your computer and use it in GitHub Desktop.
cat a file from gist, search by username + filename
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
notags() { | |
while read line; do | |
echo $line | sed -e "s/<[^>]*>/ /g" -e "s/ / /g" | |
done | |
} | |
user=$1 | |
wanted=$2 | |
list=`curl -s http://gist.github.com/api/v1/xml/gists/${user}` | |
repos=`echo $list | xmlstarlet sel -t -c "gists/gist/repo" | notags` | |
for repo in $repos; do | |
files=`echo $list | xmlstarlet sel -t -c "gists/gist[repo=${repo}]/files/file/file" | notags` | |
for file in $files; do | |
if [[ $file == $wanted ]]; then | |
curl -s https://gist.github.com/raw/$repo/$file | |
fi | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
requires xmlstartlet, curl