This line is incorrect. Insted of assigning the result to the variable NAME, you are redirecting the output of the command to a file, whose name is stored in the variable NAME (which I presume is currently undefined).
echo "$name" | tr '[a-z]' '[A-Z]' >$NAME
I think this will give the result you expect:
name=$(echo "$name" | tr '[a-z]' '[A-Z]')
# or this, but I prefer the previous syntax
name=`echo "$name" | tr '[a-z]' '[A-Z]'`
Similarly with $out, you need to make the same change.
Thanks for the reply but this thing won't work since I am converting lowercase to Uppercase so that the grep can work b'coz in the file everything is in uppercase. I m doing something wrong in grep statement not in awk one.
Nothing here is ksh-specific, so I changed it to use /bin/sh
#!/bin/sh
name=$1
print "$name"
nawk -v name="$1" '$1 == toupper(name){print""$1" is husband of "$2" & father of "$3""}'
exit 0
I think you are expecting the redirections (>$out etc) to assign the output to a variable, but it doesn't do that. It sends the output to a file whose name is $out
Like Annihilannic tried to explain, the syntax for assigning the output from a command to a variable is var=`commands` or equivalently var=$(commands) ... but unless you need the variable for something else than just printing it immediately, using variables at all is unnecessary.