Skip to content

Instantly share code, notes, and snippets.

@wacko
Last active June 21, 2017 20:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save wacko/4e6c61f7c6d16881c8ff02e28bd39008 to your computer and use it in GitHub Desktop.
Save wacko/4e6c61f7c6d16881c8ff02e28bd39008 to your computer and use it in GitHub Desktop.
List all the different gems on your Gemfile.lock
#!/bin/bash
print_gems() {
awk '/([[:alnum:]_]+) \(/{ print $1 }' Gemfile.lock | sort -u
}
count() {
grep -c ^
}
if [ "$1" == "-c" ]; then
print_gems | count
else
print_gems
fi
@wacko
Copy link
Author

wacko commented Jun 21, 2016

$ cat Gemfile
source 'https://rubygems.org'
gem 'rails'
$ gemcount
actionmailer
actionpack
...
$ gemcount -c
36

@wacko
Copy link
Author

wacko commented Jun 21, 2016

I like grep -c ^ over wc -l as it doesn't print spaces ;-)

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