Created
July 28, 2018 19:23
-
-
Save stuthedew/2e3dee8679d0ec949048e517bf76937f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# =================================================================== | |
# 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