Question: 4) Write a Bash shell script named shiftCase.sh that a. Convert the supplied string arguments to all uppercase or all lowercase depending on the supplied

4) Write a Bash shell script named shiftCase.sh that

a. Convert the supplied string arguments to all uppercase or all lowercase depending on the

supplied flag

b. If the flag is -l performs the lowercase conversion and print the result to screen

c. If the flag is -u performs the uppercase conversion and print the result to screen

CPSC-254 Fall 2017 Prof. Thomas Nguyen Assignment #4 pg. 2

d. Only alphabetic characters are converted. Non-alphabetic characters (such as numbers,

punctuation marks, etc.) are not affected.

e. Exactly one of two options (-l and -u) must be specified. If none are specified, or both are

specified, or something other than -l or -u is specified, print an error message and exit.

f. If there is no argument specified, then print an error message and exit

g. If there is more than one argument, convert each argument and print each result on a

separate line

h. Hint: Use getopts and tr commands

5) Write a Bash shell script named getAbsPath.sh that does the following:

a. Take 1 or more relative paths to files or directories as arguments and print the

corresponding absolute paths

b. For each argument given on the command line, print the argument as is, followed by => ,

followed by the corresponding absolute path of the argument

c. If argument is a file or directory that doesnt exist, print does not exist after =>

d. If argument is already an absolute path, print already absolute path after =>

e. If argument is a symbolic link you do not have to follow the link, just determine the absolute

path of the symbolic link

f. If there is no argument, print an error message and exit

g. Important: You can NOT use realpath or readlink commands.

h. Hint: Use pwd and basename and dirname commands

need 5 ASCII text files, one for each script. The files must be ready for execution, i.e.

requiring no changes (other than setting the execute permission bits).

use the following function to determine whether something is a valid integer.

isInteger() {

if [[ $1 =~ ^[+-]?[0-9]+$ ]]; then

return 0

else

return 1

fi

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!