#!/bin/sh -u # Exercise #3 myscript.sh sample solution # ------------------------------------------------------------------ # Syntax: # $0 (no arguments) # ------------------------------------------------------------------ # Purpose: # Create a new, empty directory. (Remove any previous copy first.) # Create some files and links. Rename some files. # Use the sort, uniq, sum, diff, head, and tail commands. # ------------------------------------------------------------------ # Student Name: Ian! D. Allen # Algonquin EMail Address: alleni # Student Number: 000-000-000 # Course Number: NET 2003 # Lab Section Number: 010 # Professor Name: Ian Allen # Assignment Name/Number/Date: Exercise 3, due January 24, 2005 # Comment: Sample solution (missing comments) # ------------------------------------------------------------------ # Use standard search path, friendly umask, ASCII collating and sorting. # PATH=/bin:/usr/bin ; export PATH umask 022 LC_COLLATE=C ; export LC_COLLATE # 5a rm -rf "test ex3 dir" # 5b mkdir "test ex3 dir" cd "test ex3 dir" # 5c mkdir "one" ".two" '.three *' '.' # 5d echo 'happy $hopping day' > happy # 5e ln happy one/happy ln happy .two/happy ln happy '.three */happy' ln happy './happy' # 5f ls -l '.three */happy' # 5g sum "./happy" # 5h mv one/happy 'one/' mv .two/happy '.two/*a*' # 5i echo 'no prompt C:\' >> 'one/' # 5j # bonus: sort -r */* .??*/* >sorted sort -r one/* .two/* '.three *'/* '.'/* >sorted wc sorted sum sorted # 5k uniq sorted >'.three */unique' wc '.three */unique' sum '.three */unique' # 5l head -1 '.three */unique' >.two/head # 5m tail -1 '.three */unique' >'./tail' wc './tail' sum './tail' # 5n diff 'one/' '.three */unique' >one/differences wc one/differences sum one/differences # 5o touch "one/empty linked" ln "one/empty linked" ".two/empty linked" ln "one/empty linked" '.three */empty linked' ln "one/empty linked" './empty linked' # 5p touch "one/empty no linked $$ $USER" touch ".two/empty no linked $$ $USER" touch ".three */empty no linked $$ $USER" touch "./empty no linked $$ $USER"