Printing in Upper

t_names1=`echo emp,dept | tr "[a-z]" "[A-Z]"`
echo $t_names1

The output is EMP,DEPT

I want the output to be 'EMP','DEPT'

Thanks !

You want the terms surrounded by single quotes?

t_names1=`echo \\'emp\\',\\'dept\\' | tr "[a-z]" "[A-Z]"`
echo $t_names1

Cheers
ZB

I just gave an example of echo here:
echo emp,dept

I am actually taking input from the user into $tab
like ... echo Enter tables
read tab (this is dynamic)

Now .........

t_names1=`echo $tab | tr "[a-z]" "[A-Z]"`

If the input into $tab is emp,dept then
I want the output to be 'EMP','DEPT'

Thanks !

Okay, change this to your needs, but something like

#!/bin/sh

echo "Enter tables..."
# separate tables by space
read tab

for term in $tab
do
  quotetab="$quotetab '$term'"
done

echo "$quotetab" | tr ' ' ',' | sed 's/,//' | tr '[a-z]' '[A-Z]'

exit 0

Works.

If I run it...

$ ./testscript
Enter tables...
my list of tables
'MY','LIST','OF','TABLES'
$

Cheers
ZB

here is one way using awk

t_names_1=`echo "emp,dept"|awk -v q="\'" 'BEGIN{FS=","} {printf("%s%s%s,%s%s%s",q,toupper($1),q,q,toupper($2),q) }' `
echo "$t_names_1"

i think this is better:


read input

output=`echo ${input} | sed -e "s/^/\'/g" -e "s/$/\'/g" -e "s/,/\',\'/g" | tr '[a-z]' '[A-Z]'`