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.