Reference no: EM131554127
Writing a few scripts
Part 1 - Bash Scripting
Write a bash script that takes two inputs, a directory path and the name of a text file that will be used for output.
The script should list the contents of the specified directory and output the permissions, file size, and filename of each file in the directory into the output text file.
Run the script on the var and sys directories and save the two outputted text files.
HINT: It may be useful to use the tr command to reduce the number of white spaces embedded in the output of the ls -l command.
Part 2 - Python Scripting
Write a Python script that takes two inputs, a directory path and the name of a text file that will be used for output.
The script should recusively search through the contents of the directory and add up the file sizes of each file to get a total directory size. The script should output the name of each file in the directory on a new line with the total directory size and directory path outputted after the files.
Run the script on the var and sys directories and save the two outputted text files.
Part 3 - Powershell Scripting
Write a Powershell script that takes two inputs, a directory path and the name of a text file that will be used for output. This script should perform the same function as the Python script.
The script should recusively search through the contents of the directory and add up the file sizes of each file to get a total directory size. The script should output the name of each file in the directory on a new line with the total directory size and directory path outputted after the files.
Run the script on the C:\Windows\boot directory and save the two outputted text files.
Part 4- Finish
Write the remainder of a shell script that given both a directory path and a number of files will loop from 1 to the number and create a text file named #.txt in the specified directory.
if [ "$1" == "" ] || [ "$2" == ""]
then
Usage: ./quiz.sh [directory] [number]
Example: ./quiz.sh /ouput 4
else
# your code here
fi
For instance, the example described would result in a directory named "output" containing the text files 1.txt, 2.txt, 3.txt, 4.txt