#!/bin/sh ################################################# ## upper v2.1 ## ## convert all text input to UPPERCASE ## ## ## ## input can come from eithet STDIN or a file ## ## given as a command line argument ## ## ## ## Copyright (c) 15 May 2003 Atom Emet ## ## Atom*Business-PHP.com ## ## ## ## This program is free software; you can ## ## redistribute it and/or modify it under the ## ## terms of the GNU General Public License as ## ## published by the Free Software Foundation; ## ## either version 2 of the License, or ## ## (at your option) any later version. ## ## ## ## This program is distributed in the hope ## ## that it will be useful, but WITHOUT ANY ## ## WARRANTY; without even the implied warranty ## ## of MERCHANTABILITY or FITNESS FOR A ## ## PARTICULAR PURPOSE. See the GNU General ## ## Public License for more details. ## ## ## ## You should have received a copy of the ## ## GNU General Public License along with this ## ## program; if not, write to ## ## the Free Software Foundation, Inc. ## ## 59 Temple Place - Suite 330 ## ## Boston, MA 02111-1307, USA ## ################################################# ######################################## ## allow either zero or one arguments ## ######################################## if [ "${#}" -gt '1' ] then ############################################### ## if more than one argument is given, ## ## echo an error message into STANDARD ERROR ## ## and exit leaving an exit status "1" ## ############################################### echo 'upper: One file at a time' >&2 exit 1 fi ####################################################### ## check if an argument is given on the command line ## ####################################################### if [ "${#}" = '1' ] then ######################################################## ## if there's an argument, check that the file exists ## ######################################################## if [ -e "${1}" ] then ########################################################### ## if the file specified on the command line does exist, ## ## input comes from that file ## ########################################################### cat "${1}" | tr '[a-z]' '[A-Z]' exit 0 else ############################################################### ## if the file specified on the command line does not exist, ## ## echo an error message into STANDARD ERROR ## ## and exit leaving an exit status "2" ## ############################################################### echo "upper: No such file or directory \"${1}\"" >&2 exit 2 fi else ################################################## ## if no file is specified on the command line, ## ## then input comes from STANDARD INPUT ## ################################################## tr '[a-z]' '[A-Z]' exit 0 fi