Basic Bash Shell
344 Shell Programming

This is an optional assignment.  If you are confident that you can perform all the tasks in this assignment, you do not have to attend lab and you do not have to demonstrate that you can perform these tasks.

1) Run two text based interactive applications (such as an editor) using a single window.  Demonstrate how to switch between the two applications.

2) Redirect the standard output of an application to a file.  Redirect the standard error to a different file.

3) Redirect the standard output and standard error of an application to a single file.

4) Append the standard output of an application to a file.

5) Using Bash's meta-characters, how would you specify each of the following:


6) Print your PATH variable.  Add a new directory to your PATH variable.  Demonstrate the shell is using the updated patth.

7) Create a process and stop it (using ctrl-Z).  Then use ps to find the PID of this process.  Then kill it using the kill command.  Us ps again to make sure the process was killed.

8) Type the following commands:

$ ls
$ date
$ clear
$ !!

What does the "!!" do?
Now type this

$ !d

What does the "!d" do?

Use the up-arrow and down-arrow to move through the command history

(Note: if you are a vi/vim user you can set bash so you can use the vi/vim edit commands (<esc> h j k l, etc)).

History will show you the entire command history.  You can execute a command in the history using !#

$ history
.... lots of commands here ---
1009     ls
1010    ls -l *.c *.h
1011    clear
$

If I want to execute the second ls I could type

$ !1010

Use the history command and the !# command to execute a command again

9) Command editing

When you use the up-arrow and down-arrow to traverse the command history you can edit the command.

Use the up-arrow to find a previous command

Use the left-arrow, right-arrow, and delete keys to modify the command

10) File completion

Change directories to my 344 public html directory

$ cd ~tyson/344

Now experiment with file completion <tab>

$ ls s <tab> <return>

$ ls a <tab> <tab>

What is happening?

11) The sort command sorts its input.  If you pass it a "-r" it will sort in reverse.  How can we use sort in combination with ls to show all the files in a directory sorted in reverse order?

12) Do the following commands:

$ cd /usr/lib
$ ls

What happened?

What can you do to actually see all the files in this directory?