Skip to content

Instantly share code, notes, and snippets.

@nibalizer
Created March 10, 2015 22:57
Show Gist options
  • Save nibalizer/c1ea8e5a389b99c4df65 to your computer and use it in GitHub Desktop.
Save nibalizer/c1ea8e5a389b99c4df65 to your computer and use it in GitHub Desktop.
#!/bin/bash
echo '['
pkgs=`dpkg -l `
IFS='
'
count=0
for pkg in $pkgs
do
if [ $count -le 4 ]; then
count=$((count + 1))
continue
fi
installed=`echo $pkg | awk '{print $1}'`
name=`echo $pkg | awk '{print $2}'`
version=`echo $pkg | awk '{print $3}'`
arch=`echo $pkg | awk '{print $4}'`
description=`echo $pkg | awk '{print $5}'`
echo -n '{"name":' '"'$name'", '
echo -n '"installed":' '"'$installed'", '
echo -n '"arch":' '"'$arch'", '
echo '"description":' '"'$description'"},'
done
echo '{}'
echo ']'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment