IT 244: Introduction to Linux/Unix
Homework 6
Due
Sunday, October 13th at 11:59 PM
What You Need to Do
- Create the script hw6.sh
with Unix commands that will do what is described in the steps
below
- This file must be in an hw6
directory under your hw directory
Setup
-
From your home directory go to your it244
directory
cd it244
- Go to your hw directory
cd hw
- Create an hw6 directory
mkdir hw6
- Enter this new directory
cd hw6
- Create hw6.sh
nano hw6.sh
Specification
- Create the file hw6.sh inside
your hw6 directory using
nano
- Write the Unix command to perform the action specified
by each step
- Be sure to write a Step comment before the Unix commands for each step
-
Run a command which will show how much free space exists on the file system.
You must use an option which will show the space in a way that
is easy for human beings, like us, to understand.
-
Run
cat
with an option that prints to the terminal a help message for this command.
-
Print to the terminal the value of a variable that shows where the shell will look
for an executable file to match the command you typed at the terminal.
-
In ~ghoffman/course_files/it244_files there is a file named
hello.sh.
Stay in your hw6
directory and run hello.sh using an absolute pathname.
Because this script is executable, you do not need to type bash
when running it.
If you run this script using bash
on the command line, you will lose points.
-
Copy hello.sh to your hw6 directory
using the same pathname you used above.
Run this copy of hello.sh using a relative pathname.
You must do this while staying in your
hw6 directory.
-
In the directory /home/ghoffman/course_files/it244_files,
you will find a red_sox.txt file.
Stay in your hw6 directory.
Using redirection run grep
on red_sox.txt to
find all games the Red Sox have won and sending the results to the file
red_sox_wins.txt.
DO NOT COPY red_sox.txt to your hw directory.
-
List the contents of your current directory.
Print to the terminal the exit status of the command you just ran.
Try to list the contents of a directory that does not exists like xxxxxxx.
Print to the terminal the exit status of the command you just ran.
-
Stay in your hw6 directory.
Using ls
and output redirection, create a file named dir_listing.txt
that contains the list of files and directories in your home directory.
-
Stay in your hw6 directory.
Using redirection, create a file named list.txt containing a list
of all the users currently logged in.
-
Stay in your hw6 directory.
Using redirection, add a listing of the contents of your hw6 directory to
dir_listing.txt.
That is, I want you to keep the original contents of dir_listing.txt intact
while running ls
of your current directory to it.
Testing
Copyright © 2020 Glenn Hoffman. All rights reserved. May not be reproduced without permission.