Replace script

I'm new to UNIX and I am trying to figure out how to get started on this. I need to write a script, �replace� that will process three or more command-line arguments as <search string>, <replace string>, and <file extension 1>, <file extension 2> � (one or more), to replace all occurrences of <search string> by <replace string> of all files with the given extensions: *.<file extension 1>, *.<file extension 2> � in the current directory. Temporary files may exist during execution but not at the end.

Assuming I do this correctly, I should get something like

$ ls *.txt *.dat
abc.txt xyz.dat
$ cat abc.txt
course number cs333
homework 4
$ cat xyz.dat
333 miles away.
33 is not a factor of 333.
$ ./replace 333 4444 txt dat
$ cat abc.txt
course number cs4444
homework 4
$ cat xyz.dat
4444 miles away.
33 is not a factor of 4444.

If I was just doing single line commands, replacing specific items wouldn't be that hard, but in a shell script, I'm sort of lost. I think I might want to use the user input and then do a grep search on the file and replace it? I have absolutely no idea.

Is this homework? Because this can easily be done with man sed (POSIX).

Seem like homework from the posters question. Let's close and reminder poster of the rule about this:

Do not post classroom or homework problems in the main forums. Homework and coursework questions can only be posted in this forum under special homework rules.

Please review the rules, which you agreed to when you registered, if you have not already done so.

More-than-likely, posting homework in the main forums has resulting in a forum infraction. If you did not post homework, please explain the company you work for and the nature of the problem you are working on.

If you did post homework in the main forums, please review the guidelines for posting homework and repost.

Thank You.

The UNIX and Linux Forums.