(Computer Engineering) Linux Shell -bash {No plagiarism}

Question 1

Linux Bash cleanUp.sh Script

Purpose:

This is about keeping a directory free of “junk” files. To be specific, we want to remove files that are backups and auto-saved versions.

Procedure:

1. Create a file “cleanUp.sh”. Use this file to write your script.

2a. Develop a bash function called cleanUp() that deletes all backup and auto-save files from the given directory.

2b. Assume that names of back up files end in either: (1) ~ or (2) .bak

and (3) auto-save files have names beginning with a #.

3. Develop a test harness [https://en.wikipedia.org/wiki/Test_harness] that tests the cleanUp() procedure.

The test() procedure should:

(1) create a new directory named TEST in the current directory

(2) create a few files (say a 4 each of names chosen by you) that fit the three categories of junk files in TEST

(3) ls -l the TEST directory

(4) invoke cleanUp TEST, and again

(5) ls -l the TEST directory.

For your answer:

1. Copy-paste the result of ls -l in the TEST directory prior to running your script.

2. Copy-paste the command line you used to run your script.

3. Copy-paste the result of ls -l in the TEST directory after running your script.

4. Copy and paste your cleanUp.sh file to the answer field for this question.

The construction must be your own.

Question 2

In Windows use Python to construct a Pipeline: Construct a pipeline with two pipes and an input redirection and an output append-redirection as in: c1 | c2 | c3 < inputInfo.txt >> outputCollection.txt

The above need not be the same as what you did in Linux for a previous lab, but should be “useful”, and you are choosing what the c1, c2, and c3 are and their arguments, if any.

The commands must be executable, assembled in the correct order, and the output should match your explanation.

To answer this question:

1. Copy and paste your command text

2. Explain what your pipeline construction does.

3. Copy and paste your command line output.

The construction must be your own.

Question 3

Windows Python cleanup.py

Purpose:

In Windows, develop a Python 2.x script, cleanUp.py, equivalent to the cleanup Bash script from a previous question. Use standard windows commands or python functions.

Procedure:

1. Your script must delete all backup and auto-save files from the given directory.

2. Assume that names of back up files end in either (1) ~ or (2) .bak

and (3) auto-save files have names beginning with a #.

The test() procedure should:

(1) create a new directory named TEST in the current directory

(2) create a few files (say 4 each of names chosen by you) that fit the three categories of junk files in TEST

(3) Use the Windows cmd program and the Windows DIR command to show the contents of a TEST directory before running your script

(4) invoke cleanUp.py, and again

(5) Use the DIR command to show the contents of the TEST directory after you ran cleanUp.py.

For your answer:

1. Provide the python version you used (2.7.0 or 3.0.1+)

2. Copy paste the results of the Windows DIR command showing the contents of a TESTdirectory before and after running your cleanup.py script.

3. Copy and paste your cleanUp.py to the answer field for this question.

The construction must be your own.