Skip to content

Instantly share code, notes, and snippets.

@gswallow
Created October 23, 2013 21:14
Show Gist options
  • Save gswallow/7126857 to your computer and use it in GitHub Desktop.
Save gswallow/7126857 to your computer and use it in GitHub Desktop.
Ever want to get the latest versions of your cookbooks to include them in your environment manifests?
#!/bin/bash
spaces=${1:-0}
if [ "$[$spaces-$spaces]" -ne "0" ]; then
spaces=0
fi
i=0
while [ $i -lt $spaces ]; do
begin="$begin "
i=$[$i+1]
done
grep '^version' cookbooks/*/metadata.rb | \
sed -e 's/cookbooks\//"/' | \
sed -e 's/\/metadata.rb:version/":/' | \
sort -k1 | \
awk '{ printf "%-24s %s\n", $1, $2}' | \
sed -e "s/[\'\"]\([0-9]\)/\"= \1/" | \
sed -e "s/[\'\"]\$/\",/" | \
sed -e '$s/,$//' | \
sed -e "s/^/$begin/" | tee newest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment