#!/bin/bash # Exam 2020/09/14 - Exercise 10 # Check correct number of parameters if [ $# -lt 1 ]; then echo "Usage: ./prog.sh " exit 1 fi # Read file line by line while read line; do # Compute number of words in line n=$(echo $line | wc -w) # If line has an odd number of words convert it to lower case if [ $[$n%2] -eq 1 ]; then echo $line | tr [A-Z] [a-z] fi # If line has an even number of words convert it to upper case if [ $[$n%2] -eq 0 ]; then echo $line | tr [a-z] [A-Z] fi done < $1 exit 0