#!/bin/ksh
ERROR1="error:can only use 0 or 1 arguments.\nusage:maxlines.sh[directory]"
ERROR2="error:argument must be a Directory.\nusage:maxlines.sh[directory]\n"
if [[ $# -gt 1 ]]
then
printf "$ERROR1"
exit 1
fi
DIR="."
if [[ $# -eq 1]]
then
if[[ -d $1 ]]
then
DIR="$1"
else
printf "$ERROR2"
exit 1
fi
cd $DIR
FILE=$(wc-l `ls` 2>/dev/null | sort -bn | Tail -n 2 | head -n 1)
printf "File `echo $FILE | awk '{print $2}'` has the maximum lines with `echo $1| awk '{print $1}'` lines.\n"
exit 0
works here...I note that you provide no screenshots to support just how it's not working. You might want to step your way across the pipes to ensure each progressive leg provides what you're looking for...before handing it off to the subsequent print statement.
You might also drop the embedded `ls` and go with a globbed * approach: