Explore BrainMass
Share

Shell Programming Input Commands

This content was STOLEN from BrainMass.com - View the original, and get the already-completed solution here!

Write a shell program which:

- Get input from command line file1 & file2
- Copy file1 to file2

- Check if there is exactly 2 filenames, if not, printout error message
- Check if file1 is the same as file2, if yes, printout error message

Thanks!

© BrainMass Inc. brainmass.com October 24, 2018, 10:37 pm ad1c9bdddf
https://brainmass.com/computer-science/programming-language-theory/shell-programming-input-commands-165061

Solution Preview

#!/bin/bash

#Write a shell program which:

#-Get input from command line file1 & file2
#-Copy file1 to file2

#-Check if there is exactly 2 filenames, if not, printout error message
#-Check if file1 is the same as file2, if yes, printout ...

Solution Summary

A shell program that checks filename equality.

$2.19
See Also This Related BrainMass Solution

Shell Script to Convert Students Marks to Grades

Also I am trying to append my newly created PS1 Command Prompt to a file how do I do that?

Please also Provide the step by step instructions so that I too can try and do these exercises.

Project 6-4
In this project, you will convert pseudo code that uses a decision structure into a shell script. The script then will accept three grades, calculate an average, and then display a letter grade based upon the average. You will need to use either the (if) statement or the (case) statement to implement this script.

1. Log in to the Linux system as a user, and then open a Terminal emulation window.
2. Create a shell script named Project6-4 in your $HOME/bin directory.
3. Convert the following pseudo code into code for the script:
Read in three grades from the keyboard
Average the grades

Display the appropriate letter grade for the number grade using this scale:
90 to 100: Display a letter grade of "A"
80 to 89: Display a letter grade of "B"
70 to 79: Display a letter grade of "C"
65 to 69: Display a letter grade of "D"
0 to 64: Display a letter grade of "F"
Insert appropriate comments

4. Save the script, quit the editor, and then make the script executable.
5. Execute the script and then input 100, 90, and 100 when prompted for each grade.
6. Record the output.
7. Execute the script again. This time input 99, 68, and 70 when prompted for each grade.
8. Record the output.
9. Execute the script one last time. Input 80, 96, and 72 when prompted for each grade.
10. Record the output.
11. Close your window, and then log out.

View Full Posting Details