Bash script to install Gems


I looked all over and couldn’t find a bash script which could check and if missing install a list of gems. I had to hack my own up:

GEMS=( `cat gems.txt` ) # gems.txt has one gem name per line

for gem in "${GEMS[@]}”; do
  found=`gem list $gem | grep -i $gem`
  if [ "$found" != "" ]; then
    parts=( $found )
    echo “Found ${parts[0]} ${parts[1]}”
    continue
  fi

  echo “—————————”
  echo “Installing $gem”
  sudo gem install $gem -y
  echo “—————————”
done

Information and Links

Join the fray by commenting, tracking what others have to say, or linking to it from your blog.


Other Posts
Morning Brew #85
Morning Brew #84

Write a Comment

Take a moment to comment and tell us what you think. Some basic HTML is allowed for formatting.

Reader Comments

Be the first to leave a comment!