Printing in Upper


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Printing in Upper
# 1  
Old 11-19-2004
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 !
# 2  
Old 11-19-2004
You want the terms surrounded by single quotes?
Code:
t_names1=`echo \\'emp\\',\\'dept\\' | tr "[a-z]" "[A-Z]"`
echo $t_names1

Cheers
ZB
# 3  
Old 11-19-2004
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 !
# 4  
Old 11-19-2004
Okay, change this to your needs, but something like
Code:
#!/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...
Code:
$ ./testscript
Enter tables...
my list of tables
'MY','LIST','OF','TABLES'
$

Cheers
ZB
# 5  
Old 11-19-2004
here is one way using awk
Code:
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"

# 6  
Old 11-23-2004
another solution

i think this is better:

Code:
read input

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

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Lower to upper..tr + awk ?

I have a file that has a pattern 2 lines, blanktwo line If encountering the first line, the 2nd line need to be converted to UPPERCASE...or...conver the 2nd line after ablank into uppercase Is there a 'tr' function in awk..(probably the best tool over sed) ? i.e. ......................... (6 Replies)
Discussion started by: stevie_velvet
6 Replies

2. Shell Programming and Scripting

Upper case letter match

Hi, im able to search for string in a file (ex: grep -w "$a" input.txt). but i have to search for the uppercase of a string in a file where upper case of the file content matches something like below. where upper("$a")== converted to upper case string in (input.txt) can someone please provide... (5 Replies)
Discussion started by: p_satyambabu
5 Replies

3. Shell Programming and Scripting

Upper and Lower case

Hi, I think this is a weird problem. I have two files...one with all UPPER case and the other one with a mix of upper and lower. Match each record in file1 against record in file2, if they match, then change the record in file1 to that of record in file2. Thanks in advance. (2 Replies)
Discussion started by: jacobs.smith
2 Replies

4. UNIX for Dummies Questions & Answers

Sco Unix printing : jobs hangs in queue - printing via lp versus hpnpf

Hi, We have a Unix 3.2v5.0.5. I installed a printer via scoadmin, HP network printer manager with network peripheral name (hostname and ipadres are in /etc/hosts). This is the configuration file : Code: root@sco1 # cat configurationBanner: on:AlwaysContent types: simpleDevice:... (0 Replies)
Discussion started by: haezeban
0 Replies

5. Windows & DOS: Issues & Discussions

Linux to Windows Printing: PDF starts printing from middle of page.

We are using Red Hat. We have a issue like this: We want to print from Linux, to a printer attached to a Windows machine. What we want to print is a PDF. It prints, but the printing starts from the middle of the page. In the report, there is no space at the top but still printing starts from the... (5 Replies)
Discussion started by: rohan69
5 Replies

6. Shell Programming and Scripting

lower to upper case in ksh

What is the command to change the contents of a file to UPPER case. Here in this file below you see some characters are Sp, Ch 1200812270046581 22885072800000652 B86860003OLFXXX592123320081227 22885029800000652 B86860003ODL-Sp592123420081227 22885093700000652-B94030001ODL-Ch592123520081227... (4 Replies)
Discussion started by: kshuser
4 Replies

7. Shell Programming and Scripting

convertin in to upper case

write a shell script that accepts one or more file name as arguments and converts all of them to uppercase,provided they exist in the current directory:b::b::b: (2 Replies)
Discussion started by: shawz
2 Replies

8. UNIX for Dummies Questions & Answers

File xfer upper cap?

Is there any setting required to define upper cap for a user to restrict the file transmission? If yes, what it is & can non-admin user be able to revoke that? (0 Replies)
Discussion started by: videsh77
0 Replies

9. UNIX for Advanced & Expert Users

Printing Problems in unix ... ( Bar-cdoe - Ip Printing)

Hi guys ... i need ur help with some printing problem in unix ... first prob. : i wanna print from my NCR unix to an Win NT , Ip based printing server ( HP JetDirect ) . My issue , is it possible to print directly to an Ip address from unix ? How do i make it work to get any results ?... (3 Replies)
Discussion started by: QuickSilver
3 Replies

10. Shell Programming and Scripting

Upper And Lower Case

Hi! I pass a parameter to a script code and I have to make it upper case before use: $ MyShell aBcDe script code: UpperVariable=function($1) I can't know how make function, maybe some sed option? Thank You, PARIDE (1 Reply)
Discussion started by: pciatto
1 Replies
Login or Register to Ask a Question