Last active
October 22, 2019 08:09
-
-
Save argraur/7430dc5e72504ad32efbc5e3eedca06d to your computer and use it in GitHub Desktop.
prop
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
#!/bin/bash | |
if test -z $1 | |
then | |
echo "Usage: prop <mode> <file> <prop> [value]" | |
echo "mode = get / set" | |
echo "file = your .prop file" | |
echo "prop = something like ro.build.blah" | |
echo "value = only if using set, define value there." | |
exit 1 | |
fi | |
if test $1 = "get" | |
then | |
if test -z $(cat $2 | grep $3=) | |
then | |
echo "ERROR: this prop is not defined. Use prop set" | |
exit 1 | |
fi | |
echo $(cat $2 | grep $3=) | |
exit 0 | |
fi | |
if test $1 = "set" | |
then | |
# set | |
if test -n $(cat $2 | grep $3=) | |
then | |
sed "s/$(cat $2 | grep $3=)/$3=$4/" <$2 >$2_tmp && mv $2_tmp $2 | |
exit 0 | |
fi; | |
echo $3=$4 >> $2 | |
exit 0 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment