Due August 22, Noon
Purpose:
To gain further experience in programming with the C-shell using shell variables , metavariable, and shell control structures, such as if-then-else, switch, foreach.
Assignment:
Write a C-shell script called hw4, place it into your subdirectory 20ECES620801, and make the file executable to yourself.
In your current directory you may want to change all filenames that contain the string letter to filenames with the string memo instead. You may think that the command
mv *letter* *memo*
should work, but it does not. Your script hw4 should accomplish this. It has to be called with 2 parameters with the first parameter the original string, the second the replacement string. To the given example it would be
hw4 letter memo
Also, implement the option -d which allows the user to enter a source and destination directory. The user would be prompted to enter the source directory and the destination directory, and your script will perform the operation described above, except that the files will be moved from the destination to the source directory, e.g.,
hw4 -d letter memo
Enter source directory: ~/620
Enter destination directory: ./UNIX
For each file that is moved have your program check whether the changed-name file already exists (in the destination directory or current directory if -d option is not used). If it does, give the user the option of overwriting the file, i.e., no (do not overwrite), yes (overwrite) or all (overwrite files without querying the user again).
Do not use any temporary files. and provide the standard comments at the beginning of your script. Output an appropriate usage message if the number of parameters used is different from 2. Also, print a message if the source or destination directory does not exist.