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

28 lines
585 B
Bash
Raw Normal View History

2001-07-10 14:25:50 +00:00
#!/bin/bash
# Changes a file to all uppercase.
2008-11-23 22:43:47 +00:00
E_BADARGS=85
2001-07-10 14:25:50 +00:00
2008-11-23 22:43:47 +00:00
if [ -z "$1" ] # Standard check for command-line arg.
2001-07-10 14:25:50 +00:00
then
echo "Usage: `basename $0` filename"
exit $E_BADARGS
fi
tr a-z A-Z <"$1"
2001-07-10 14:25:50 +00:00
2001-09-04 13:27:31 +00:00
# Same effect as above, but using POSIX character set notation:
# tr '[:lower:]' '[:upper:]' <"$1"
2001-07-10 14:25:50 +00:00
# Thanks, S.C.
2011-08-29 23:59:19 +00:00
# Or even . . .
# cat "$1" | tr a-z A-Z
# Or dozens of other ways . . .
2001-07-10 14:25:50 +00:00
exit 0
2005-06-05 14:39:50 +00:00
# Exercise:
# Rewrite this script to give the option of changing a file
#+ to *either* upper or lowercase.
2011-08-29 23:59:19 +00:00
# Hint: Use either the "case" or "select" command.