Skip to content

Instantly share code, notes, and snippets.

@stuthedew
Created July 28, 2018 19:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stuthedew/2e3dee8679d0ec949048e517bf76937f to your computer and use it in GitHub Desktop.
Save stuthedew/2e3dee8679d0ec949048e517bf76937f to your computer and use it in GitHub Desktop.
#
# ===================================================================
# Purpose: Updates Python packages using Pip
# Called From: Command line
# Author: Stuart Feichtinger
# Notes: Global updater using pip
# Revsion: Last change: 07/28/18 by SF :: First Commit
# ===================================================================
#
#!/bin/bash
#Create temp file to hold list of outdated packages
tmpfile=$(mktemp /tmp/pupdate-script.XXXXXX)
echo "Running Pip Updater..."
#List outdated pacakgaes | clean up output | remove header text | output files and store in tempfile
pip list --outdated | cut -d' ' -f 1 | tail +3 > $tmpfile
if [ -s $tmpfile ] #Check if any outdated packages
then
echo "Updating the following Pip packages:"
cat $tmpfile
cat $tmpfile | xargs -n 1 pip install -U
else
echo "Already up-to-date."
fi
echo "Done"
#Clean up temp file
rm "$tmpfile"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment