4.11 Text processing - HTML4 Labs4.9 4.10 Shell script -- swapdir

4.10 Shell script -- swapdir

Using a text editor, create a shell program. Your shell program will probably need to use cut, ls, expr, grep, paste, wc, cat, hostname, and cal. It will probably also use pipes, redirection, variables, and command substitution.

Call your shell script swapdir.

Your program should do the following:

  1. "Display" the number of days in the current month. For example:
    September 1996 has 30 days
    
  2. "Display" the number of directories in the root directory. For example:
    The root directory on gort has 12 directories
    
  3. "Display" the root directory in the following format. This is what the command
    username@gort ~ $ ls -l /
    
    gives:
    drwxr-xr-x  2 root    2048 Jun 30 14:26 bin
    drwxr-xr-x  2 root     512 Jun  2 15:59 bsd-src
    -rw-r--r--  1 root  147456 Sep  7 14:25 core
    -rw-r--r--  1 root     925 Apr  8 18:00 dflt.DECterm
    drwxr-xr-x  3 root    3072 Sep  8 14:45 dev
    drwxr-xr-x  6 root    6656 Sep  9 22:25 etc
    lrwxr-xr-x  1 root       7 Feb 24  1993 lib -> usr/lib
    drwxr-xr-x  2 root    8192 Feb 24  1992 lost+found
    drwxr-xr-x  2 root     512 Aug  7  1992 mnt
    drwxr-xr-x  2 root     512 Feb 24  1993 opr
    drwxr-xr-x  3 root     512 Aug  3 12:44 public
    lrwxr-xr-x  1 root       7 Feb 24  1993 sys -> usr/sys
    drwxrwxrwt  5 root    1024 Sep 12 18:46 tmp
    -rw-r--r--  1 root   11568 Jul 24  1992 ultrixboot
    drwxr-xr-x 27 root    1024 Jun 10 11:28 usr
    drwxr-xr-x  9 root     512 Aug 19 15:43 usr2
    -rwxr-xr-x  1 root 3448280 Feb 24  1993 vmunix
    
    This is what I would like your output to look like:
    September 1993 has 30 days
    The root directory on gort has 12 directories
    
       2048 r-x  2 14:26 bin
        512 r-x  2 15:59 bsd-src
       3072 r-x  3 14:45 dev
       6656 r-x  6 22:25 etc
       8192 r-x  2  1992 lost+found
        512 r-x  2  1992 mnt
        512 r-x  2  1993 opr
        512 r-x  3 12:44 public
       1024 rwt  5 18:46 tmp
       1024 r-x 27 11:28 usr
        512 r-x  9 15:43 usr2
    
    Please note that the output only contains the directories.
Make a printout of your output and shell script, mark it with:
your name
TABER CIS137
Lab 4.10: Shell script --- dir
Please turn your lab to Louis Taber or to Pima Community College employee in room A-115 of the Santa Rita Building. Ask them to place it in the dark blue folder in Louis Taber's mailbox.
Instructor: ltaber@pima.edu ** My new Home at GeoApps in Tucson ** The Pima College Site

4.11 Text processing - HTML4 Labs4.9 4.10 Shell script -- swapdir