LDP/LDP/guide/docbook/abs-guide/ex49.sh

23 lines
442 B
Bash

#!/bin/bash
# Changes a file to all uppercase.
E_BADARGS=65
if [ -z "$1" ] # Standard check for command line arg.
then
echo "Usage: `basename $0` filename"
exit $E_BADARGS
fi
tr a-z A-Z <"$1"
# Same effect as above, but using POSIX character set notation:
# tr '[:lower:]' '[:upper:]' <"$1"
# Thanks, S.C.
exit 0
# Exercise:
# Rewrite this script to give the option of changing a file
#+ to *either* upper or lowercase.