X interview question

String parsing questions, shell script functions