Question

In: Computer Science

Script 3: Ask the user for a file's name If the file exists, ask them if...

Script 3:

  1. Ask the user for a file's name
  2. If the file exists, ask them if they would like to (C)opy, (M)ove, or (D)elete it by choosing C, M, or D
  3. If the user chooses C, ask for the destination directory and move it there
  4. If the user chooses M, ask for the destination directory and move it there
  5. If the user chooses D, delete the file.
  6. Ensure that the user enters only C, M, or D, warning them about the mistake if they should enter something else.

Please show screenshots from the command prompt! Thank you!

Solutions

Expert Solution

echo "Enter file name"
read filename
test -f $filename && echo "press (C)for Copy, (M) Move or (D) Delete " || exit 1


read choice

if [ "$choice" = C ];
then
    echo "Enter Destination Directory"
   read dest
   cp $filename $dest
elif ["$choice" = M ];
   then
    echo "Enter Destination Directory"
    read dest

   mv $filename $dest
elif ["$choice" = D ];
   then
    rm $filename
else

    echo " press (C)for Copy, (M) Move or (D) Delete "
fi



Related Solutions

Task 2.5: Write a script that will ask the user for to input a file name...
Task 2.5: Write a script that will ask the user for to input a file name and then create the file and echo to the screen that the file name inputted had been created 1. Open a new file script creafile.sh using vi editor # vi creafile.sh 2. Type the following lines #!/bin/bash echo ‘enter a file name: ‘ read FILENAME touch $FILENAME echo “$FILENAME has been created” 3. Add the execute permission 4. Run the script #./creafile.sh 5. Enter...
Name the script thirsty.sh. Ask the user if they are thirsty. Read the user's response. If...
Name the script thirsty.sh. Ask the user if they are thirsty. Read the user's response. If they answer no or No, print an appropriate message and exit. If they answer yes or Yes, ask what they would like to drink. Read the user's response. If they answer water print "Clear crisp and refreshing." If they answer beer print "Let me see some id." If they answer wine print "one box or two." If they answer anything else print "Coming right...
Write a program that prompts the user for a file name, make sure the file exists...
Write a program that prompts the user for a file name, make sure the file exists and if it does reads through the file, count the number of times each word appears and then output the word count in a sorted order from high to low. The program should: Display a message stating its goal Prompt the user to enter a file name Check that the file can be opened and if not ask the user to try again (hint:...
Write a program that prompts the user for a file name, make sure the file exists...
Write a program that prompts the user for a file name, make sure the file exists and then reads through the file, counts the number of times each word appears and outputs the word count in a sorted order from high to low. The program should: Display a message stating its goal Prompt the user to enter a file name Check that the file can be opened and if not ask the user to try again (hint: use the try/except...
File IO Java question • Ask the user to specify the file name to open for...
File IO Java question • Ask the user to specify the file name to open for reading • Get the number of data M (M<= N) he wants to read from file • Read M numbers from the file and store them in an array • Compute the average and display the numbers and average.
Ask the user for their name Create a file called "daily.dat" within the home directory Ask...
Ask the user for their name Create a file called "daily.dat" within the home directory Ask the user for a line of text that the system should save to the file Add to the file the line of text entered by the user Ask the user for a second line of text that the system should save to the file Append at the end of the file the line of text entered by the user Create a copy of the...
c++ In this program ask the user what name they prefer for their file, and make...
c++ In this program ask the user what name they prefer for their file, and make a file, the file name should za file. Get a number from the user and save it into the create file. should be more than 20 number in any order. print out all 20 numbers in a sorted array by using for loop, last print out its total and average. At last create a function in which you will call it from main and...
Name the script while.sh. Ask the user to enter a positive integer. You can assume that...
Name the script while.sh. Ask the user to enter a positive integer. You can assume that the user will enter a positive integer (input validation for a positive number not required). Use a while loop to print all integers from 0 up to and including the integer entered. Each integer should be printed on a line by itself and nothing else should print. This is for Linux. I have not done anything on this script. Please help with simplistic commands...
Write a brief shell script that will take in a specific file name, prompt the user...
Write a brief shell script that will take in a specific file name, prompt the user whether they would like to gzip, bzip2, or xz compress the file. Depending on response, the script then ought to compress the provided file with the corresponding method
Using the given file, ask the user for a name, phone number, and email. Display the...
Using the given file, ask the user for a name, phone number, and email. Display the required information. These are the Files that I made: import java.util.Scanner; public class Demo5 { public static void main(String args[]) { Scanner keyboard = new Scanner(System.in); System.out.println("New number creation tool"); System.out.println("Enter name"); String name = keyboard.nextLine(); System.out.println("Enter phone number"); String phoneNumber = keyboard.nextLine(); System.out.println("Enter email"); String email = keyboard.nextLine(); Phone test1 = new SmartPhone(name, phoneNumber, email); System.out.print(test1); System.out.println("Telephone neighbor: " + ((SmartPhone) test1).getTeleponeNeighbor()); }...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT