#!/bin/sh # tell it what shell to # use when running this PATH=/usr/bin:/bin:/usr/local/bin # where to look for export PATH # binaries #LIST=$HOME/public_html/.7list # The data file(jasonstyle) LIST=$HOME/html/vinyl/7list.txt # The data file export LIST item=7 # Edit for item # - - - - - # # If something supplied, then do a lookup # # - - - - - # if [ "$#" -ne 0 ] # "if there were options, then # do this: lu "$@" # exec 'look it up' # exit # then quit yourself." fi add() # a function --- { # essentially a shell echo "$1=$2" >> $LIST # script inside a sort -o $LIST $LIST # script # echo "test!" # This generates a # exit # file with the fields } # divided by '=' lu() { grep -i "$1" $LIST } rem() #not really used { if [ "$#" -ne 1 ] then echo "This doesn't work if you don't tell it what to remove." exit 1 fi name=$1 # # Find number of matching entries # matches=`grep "$name" $LIST | wc -l` # # If more than one match, issue message, else remove it # if [ "$matches" -gt 1 ] then echo "More than one match; please qualify further." elif [ "$matches" -eq 1 ] then grep -v "$date" $LIST > /tmp/$USER.$$ mv /tmp/$USER.$$ $LIST else echo "$date not found." fi } # - - - - - # # Loop until a valid selection is made # # - - - - - # validchoice="" # set it null for loop until [ -n "$validchoice" ] do # - - - - # # Display menu with a long echo # # - - - - # echo ' Would you like to: [1] Check for a '$item' [2] Add a '$item' [3] Exit Please select one of the above (1-3): \c' # # Read and process selection # read choice echo case "$choice" in 1) echo "Enter artist to look up: \c" read artist lu "$artist";; # validchoice=TRUE;; 2) echo "Enter artist: \c" read artist echo "Enter title: \c" read title #echo "Enter label: \c" #read label #echo "Enter release date: \c" #read date add "$artist" "$title";; # validchoice=TRUE;; 3) exit;; # 3) echo "Enter artist to be removed: \c" # read artist # rem "$artist" # validchoice=TRUE;; 4) add;; *) echo "Bad choice";; esac done