Question

In this assignment, you will demonstrate your ability to write simple shell scripts. This is a cumulative assignment that wil2.1 Stage 1 Create a directory -/UnixCourse/scriptAsst. Within that directory, create a shell script, chExt1.sh taking two pa

0 0
Add a comment Improve this question Transcribed image text
Answer #1

****Please up-vote/like the answer even if it is at least 1% useful to you.****

****It encourages me to give answer to your question.****

Code :

chExt1.sh:

#give path executable
#!/bin/bash                  
oldName=$2                   #take 2nd command line argument into oldName variable
newName=${oldName%.*}       #remove extension of filename
newName=$newName.$1           #append desired extension
mv "$oldName" "$newName"   #rename the file actually

Screenshot :

E#give path executable #! /bin/bash oldName=$2 newName=${oldName%. newName=$newName.$1 mv $oldName $newName 2 #take 2nd c

Output :

UnixCourse/scriptAsst ] 12/30 21:25:49 CST 2019 [ 12/30 21:25:54 CST 2019 | UnixCourse/scriptAsst ] :$ echo ants > aardvark.C/UnixCourse/scriptAsst ] 12/31 00:00:41 CST 2019 [ L--n1 S ls -lt total 12 -rWxrWxr-x 1 hci hei 90 Dec 30 23:57 chExtl.sh O D

Add a comment
Know the answer?
Add Answer to:
In this assignment, you will demonstrate your ability to write simple shell scripts. This is a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Objective : Write a C Shell script which copies all files(*.java and *.class) from your home dire...

    Objective : Write a C Shell script which copies all files(*.java and *.class) from your home directory to a new one, and Analyze the new directory information such as number of files, user permissions, and disk usage. Sample Output:                                                    << CS Directory Analysis >>      Date:   ============================================================ Current Directory: /home/tomss New Directory Created : /home/tomss/pgm01 File information Total Number of files : 22 files Directory files:   0 files Plain text files:   10 files File have read permissions: 3 files File have...

  • IT 255 Milestone Two Guidelines and Rubric Overview: In this milestone, you will demonstrate your ability...

    IT 255 Milestone Two Guidelines and Rubric Overview: In this milestone, you will demonstrate your ability to create a basic script in Linux. Review the Final Project Guidelines and Rubric document to see how this milestone will prepare you for the scripting portion of the project. You will perform this milestone in Codio in the unit called "Milestone 2: Scripting." You will create this script with the vi editor. The script will combine multiple commands and simplify a repeatable task....

  • Write a SHELL SCRIPT: Write a simple shell that is similar to what we have discussed...

    Write a SHELL SCRIPT: Write a simple shell that is similar to what we have discussed in class. while (1) {//repeat forever type_prompt();//display prompt on screen read_command (command, parameters);//read input from terminal if (fork() != theta)//parent wait (NULL);//wait for child else{execve (command, parameters, theta);//execute command}} but contains enough code that it actually works so you can test it. For simplicity, you may assume that all commands are in the directory/bin.

  • Write a script using simple shell commands. The script takes a command line argument that specifies...

    Write a script using simple shell commands. The script takes a command line argument that specifies a directory dir. The script first changes directory to dir, then prints the following in sequence: (a) A line starting “Current date and time: ”. Then on the same line, the current time and date. (b) A line starting “Current directory is : ”. Then, on the same line, the absolute pathname of the current working directory. (c) An empty line (d) The line...

  • Write a bash shell script to carry out each of the following tasks: What to Do:...

    Write a bash shell script to carry out each of the following tasks: What to Do: a. Safe Delete: When you use the “rm” command in Linux, it will delete the specified files, with no chance for recovering them back later. Write a script (called srm) that will safely delete the files passed to it as command-line arguments. For example, typing the command: “srm file1 file2 file3”, the script shall not actually delete these files, but instead it shall move...

  • 1. Write 4 simple shell scripts. Each question will ask you to write one or more...

    1. Write 4 simple shell scripts. Each question will ask you to write one or more command lines to solve a problem. Put the command(s) from each problem into a file named problem1.sh, problem2.sh Note that if you want your script to be interpreted by bash, each file should start with the line: #!/bin/bash and will have one (or more, as needed) commands following it. To execute each script in bash, so you can determine if it is working or...

  • Please do it in LINUX! and please show your output as well! Thank you! Write a...

    Please do it in LINUX! and please show your output as well! Thank you! Write a simple shell script to move (rename) all *.PDF files under the current directory (if any) to *.pdf, e.g., move test.PDF to test.pdf move hello.PDF.PDF to hello.PDF.pdf move .hello.PDF.PDF to .hello.PDF.pdf and report each action, otherwise just report there are no *.PDF files.

  • Question 4 0/1 point (graded) Which of the following statements does NOT correctly describe the utility...

    Question 4 0/1 point (graded) Which of the following statements does NOT correctly describe the utility of a command in Unix? The q key exits the viewer when you use less to view a file. The command ls lists files in the current directory. The command mkdir makes a new directory and moves into it. The mv command can move a file and change the name of a file. incorrect Answer Incorrect: Try again. The mv command can move a...

  • 1. Write a function that takes as input a directory. The function will search through that...

    1. Write a function that takes as input a directory. The function will search through that directory and its full subdirectory tree, building a count of the files by their extensions. As in the lecture, use a dictionary to keep track of the counts. The return-value of this function will be a dictionary of (key,value) pairs where the key will be the file extension and the value will be the number of files with that extension. For example, for the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT