I am new to Linux and was wondering if anyone could help me with a script I have been trying to write?? In a nutshell, here is what I'm trying to accomplish:

I have a file in /var/backup that hopefully contains the word "successful".

I want to grep successful in /var/backup and if "successful" is present, replace all verbiage in the file with a simple "2", then output the file to /var/spool/XX

If the grep returns nothing, replace all verbiage in the file with a simple "1", then output the file to /var/spool/XX

If anyone could help me with this I would greatly appreciate it. Thanks.