Assignment 3
Due: February 26 th
20 points
Your first Unix shell script!! Name your code as3Code (you will create your code
using the Linux editor nano). Your script/program is to show me
both the command and the output of the command to answer each of the 10
items below.
Under the Unix operating system, create a shell script (as3Code)that consists of Unix commands that answer the following:
- Display(i.e. echo) your first and last name
- Set the variable X to be your userid using the built-in variable
- echo the value of x with a message that says, "My login id is ..."
- Show the number of words in ONLY the hidden files in your home directory
- Show the permissions and details of all of the files (including hidden) in your home directory
- The current date
- Display the contents of the PATH variable
- Set the variable, var to your last name
- Display the value of the variable var
- Search (use the find command) through /usr and all of its subdirectories for files the begin with "dir" and end with ".h"
Since this is your first shell script, let me detail the actions that you should do:
- Use nano to create the file as3Code
- On the first line of as3Code, place the following:
#!/bin/sh
- Exit nano
- Change permissions on as3Code to be executable
chmod u+x as3Code
- Determine the Linux command to answer the first question
- After you find each answer, add two lines
to your Unix shell script (i.e., program) - the first to echo the answer and the
second to execute the command.
For example, if I determined the answer was:
ls -la
I would add the following two lines to as3Code:
- echo "ls -la"
- ls -la
- Make sure you test your code!!!
- Exit nano and run your code by typing in:
- ./as3Code
- Continue this process until you have all 10 answers
To turn this assignment in:
- place your shell script named as3Code on your obsidian dropbox
by copying as3Code to YOUR subdirectory in
/home/SRUNET/ClassFolders/CPSC-207-01.0120/YOUR_FOLDER
- From within your drop box (you need to change directory to your
subfolder within /home/SRUNET/ClassFolders)
run the as3Code shell script and redirect the output to a file
named assign3.txt
- ./as3Code > assign3.txt