Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 04-15-2012
Registered User
 
Join Date: Sep 2010
Posts: 24
Thanks: 3
Thanked 0 Times in 0 Posts
Printing all 'case' variations of a word

Hey Guys & Gals,

I am trying to figure out how one would go about printing all
possible variations of letter cases in a given word.

So if for instance given the input "test123"
output would be ;

Code:
test123
Test123
TEst123
TESt123
TEST123
tEst123
tESt123
tEST123
teSt123
teST123
tesT123

etc. etc. until all case variations of 'test' have been printed.

Any pointers on the correct way to move forward greatly appreciated !
Sponsored Links
    #2  
Old 04-15-2012
Scrutinizer's Avatar
Moderator
 
Join Date: Nov 2008
Location: Amsterdam
Posts: 7,338
Thanks: 143
Thanked 1,754 Times in 1,591 Posts
Perhaps this pseudocode might be a good approach:

Code:
convert string to lowercase
while there is a lowercase character in string
do
  for every character in the string 
  do
    if current character is in [[:alpha:]]
      if current character is upper then 
        convert to lower 
      else
        convert to upper
        break
      fi
    fi
  done
done

Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
script to include filename with variations at the beginning of the file iamzesh Shell Programming and Scripting 1 03-25-2011 11:01 AM
Convert to upper case first letter of each word in column 2 cgkmal Shell Programming and Scripting 16 05-03-2010 11:27 AM
Convert first character of each word to upper case harchew Shell Programming and Scripting 3 10-23-2009 03:05 PM
printing only the middle word between two patterns tigta09 UNIX for Dummies Questions & Answers 7 09-09-2009 06:16 PM
Printing 1st column to lower case using awk pinnacle Shell Programming and Scripting 11 05-18-2009 12:18 PM



All times are GMT -4. The time now is 01:36 PM.