The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Lowercase to Uppercase ggovotsis AIX 7 10-16-2008 11:07 AM
only uppercase first character? fedora Shell Programming and Scripting 7 09-26-2008 09:12 PM
make uppercase kirkm76 UNIX for Dummies Questions & Answers 4 05-29-2007 12:28 AM
Converting to Uppercase dreams5617 Shell Programming and Scripting 3 11-12-2004 01:44 AM
uppercase to lowercase webex Shell Programming and Scripting 4 01-03-2002 02:15 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-16-2008
subrat subrat is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 4
Conversion to uppercase - tr

Hi,

I am trying to convert the $i in loop from lower to upper case but getting error like ' awk: 0602-502 The statement cannot be correctly parsed. The source line is 1.' ..

Requirement: I have many table in script XXX.sql which starting with 'ABC_','AbC_','aBc_' etc.. same thing for table starting with XYZ. I need all these table names.

Could u plz help me on that.

grep -iE "ABC_|XYZ_" /ukdw/prd/working/TDMatrix/srualcb02/ukdw/prd/bin/XXX.sql | awk '{printf("%s ",$0)}END{print "\n"}' | sed 's/,/ /g;s/ / /g' |
awk 'BEGIN{FS=" "}
{
for(i=1;i<=NF;i++)
{
fieldToCheck= $i | tr '[a-z]' '[A-Z]'
if (index($fieldToCheck,"ABC")>0){print $i};
if (index($fieldToCheck,"XYZ")>0){print $i};
}
}'
  #2 (permalink)  
Old 06-16-2008
nua7 nua7 is offline
Registered User
  
 

Join Date: Mar 2008
Location: /bin/sh
Posts: 353
Thumbs up Use backtiks and echo

Code:
fieldToCheck= `echo $i | tr '[a-z]' '[A-Z]'`
  #3 (permalink)  
Old 06-16-2008
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,308
Replace this:

Code:
fieldToCheck= $i | tr '[a-z]' '[A-Z]'
if (index($fieldToCheck,"ABC")>0){print $i};
if (index($fieldToCheck,"XYZ")>0){print $i};
with:

Code:
fieldToCheck=toupper($i)
if (index(fieldToCheck,"ABC")>0){print $i}
if (index(fieldToCheck,"XYZ")>0){print $i}
Regards
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:29 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0