#!/bin/bash
read -p 'Enter a word : ' str id
if [[ ${#str} -le 1 ]] || [[ ${#str} -ge 6 ]]; then
echo "Invalid input (Min of 2 and max of 5)!." && exit 1
idt=$((id-1))
case ${str:idt:1} in
[[:lower:]])
r='\U';
;;
[[:upper:]])
r='\L';
;;
esac
echo $str | sed -r "s/./$r&/$id"
$ ./script.sh
Enter a word : test 1
Test
$ ./script.sh
Enter a word : Test 2
TEst
$ ./script.sh
Enter a word : teST 3
tesT