create 2 text files in your home directory
touch myfile && touch test
In the test file put this in it. Adjust for your directory names etc.
# Script to test a rpm scriplet
if [ -e /home/username/myfile ]; then
mv /home/username/myfile /home/username/myfile.bak
Then to make it executable
then run the script from your terminal with
and see if it works, if so and it should, then add to the %pre section in your .spec file.
You should see the renamed file myfile.bak and myfile.itworked
If the file "myfile" is empty, nothing happens with the -s file test, only if it is not empty. If the file exists, empty or not, then the -e file test might be preferable.
If you search for common file tests you will find more assistance, this is just one.