Hour 21

1: Write a function named toLower that converts its arguments to all lowercase and outputs the converted string to STDOUT. (HINT: Use tr.)
A1: One possible implementation is
################################################
# Name: toLower
# Desc: changes an input string to lower case
# Args: $@ -> string to change
################################################

toLower() {
    echo $@ | tr '[A-Z]' '[a-z]' ;
}
2: Write a function named toUpper that converts its arguments to all uppercase and outputs the converted string to STDOUT. (HINT: Use tr.)
A2: One possible implementation is
 ################################################ # Name: toUpper # Desc: changes an input string to upper case # Args: $@ -> string to change ################################################ ...

Get Sams Teach Yourself Shell Programming in 24 Hours, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.