Skip to content

Instantly share code, notes, and snippets.

@itayd
Created December 12, 2010 14:26
Show Gist options
  • Select an option

  • Save itayd/738076 to your computer and use it in GitHub Desktop.

Select an option

Save itayd/738076 to your computer and use it in GitHub Desktop.
cat a file from gist, search by username + filename
#!/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
@itayd
Copy link
Copy Markdown
Author

itayd commented Dec 12, 2010

requires xmlstartlet, curl

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