02-28-2008
1,
0
Join Date: Feb 2008
Last Activity: 28 February 2008, 8:50 AM EST
Posts: 1
Thanks Given: 0
Thanked 0 Times in 0 Posts
i need help with pleaseeeeeeeee anyone
Write a single bash shell script which does the following:
1. It accepts a single argument which can be either the string toupper or
the string tolower. If the argument given by the user is toupper, the script
will convert all of the names of the regular files (not directories) in the
current directory to uppercase. Thus, file file.txt will become FILE.TXT, file
Report.doc will become REPORT.DOC, etc.
If the argument provided to the script is the string tolower, the files in the
current directory will be renamed to the equivalent lower case ones. For
example, Report.doc will become report.doc, etc. If the script is given no
argument, then it will not try to rename any of the files in the current
directory.
(marks 30%).
2. The files in the current directory (whether their name has changed or not
in part 1), are moved to appropriate subdirectories, where the name of the
appropriate subdirectory is the extension of the file being moved. For
example, files report1.doc, report2.doc will be moved to a subdirectory
doc, with the names REPORT1.DOC, REPORT2.DOC (assuming the
script was called with the string toupper as argument.)
If the directory does not exist, it will be created by the script. If a file does
not have an extension it will not be moved to a subdirectory.
(marks 35%).
3. There is a possibility that when a file is moved to the appropriate
subdirectory, the subdirectory already contains a file with an identical
name. Modify the script so that if such a file already exists, the moved file
will be renamed by appending the number 1 (or the next unique integer) to
it. For example, if REPORT.DOC is moved to subdirectory doc, but there is
already a file REPORT.DOC inside doc, then the moved file will be
renamed as REPORT.DOC1. If a file REPORT.DOC1 already exists inside
doc, then the moved file will be renamed as REPORT.DOC2, and so on.