Skip to content

Instantly share code, notes, and snippets.

@codecakes
Created May 10, 2017 16:33
Show Gist options
  • Save codecakes/407b21b09de2161fd84338f171acb193 to your computer and use it in GitHub Desktop.
Save codecakes/407b21b09de2161fd84338f171acb193 to your computer and use it in GitHub Desktop.
replace older package version name to newer one
#!/bin/bash
OLD="xenial"
NEW="zesty"
DPATH="/etc/apt/sources.list*"
BPATH="./play/"
TFILE="./play/out.tmp"
[ ! -d $BPATH ] && mkdir -p $BPATH || :
for f in $DPATH
do
if [ -f $f -a -r $f ]; then
/bin/cp -f $f "$BPATH/$(basename $f)"
sed "s/$OLD/$NEW/gi" "$f" > $TFILE && mv $TFILE "$(basename $f)"
else
echo "Error: Cannot read $f"
fi
done
/bin/rm $TFILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment