#!/usr/local/bin/bash # # translates a couple of dos comands to unix (ls and cls) # An example of using the read command to provide # an interactive program. # # define the prompt prompt="dos-weenie> "; # print the prompt with no newline (echo -n mean no newline) echo -n $prompt # now read from stdin and put in the variable cmd # keep doing this until we get no cmd (^D from the user) while read cmd do # if the command is dir, do an ls if [ $cmd = "dir" ] then ls else # if the command is cls, do a clear if [ "$cmd" = "cls" ] then clear else # we don't support the command echo Unrecognized command fi fi # done with the command, prompt for the next one echo -n $prompt done # force a newline echo