Printing all 'case' variations of a word


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Printing all 'case' variations of a word
# 1  
Old 04-15-2012
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 !
# 2  
Old 04-15-2012
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

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Remove matching pattern on each line with number variations

Hello folks! I have a file containing lines like this Something text 18:37Remove This: 1,111"Keep this text" Some more text 19:37Remove This: 222"Keep this text" More text 20:50Remove This: 3,333Keep this text And more text 25:50Remove This: 44,444Keep this text I would like to... (4 Replies)
Discussion started by: martinsmith
4 Replies

2. Shell Programming and Scripting

sed Command new Line not working Tried many variations

Hi I have assigned an output of a command to $I. I try to print the input and put a new line after occurrence of the hostname which is assigned to $HOST1 ( Example: pwrm16 ) . First of all I need to get rid of the Colon after the host name pwrm16: and make it pwrm16 then I want to print the... (10 Replies)
Discussion started by: mnassiri
10 Replies

3. Shell Programming and Scripting

Change first letter of a word from lower case to upper case

Hi all, I am trying to find a way to change first letter in a word from lower case to upper case. It should be done for each first word in text or in paragraph, and also for each word after punctuation like . ; : ! ?I found the following command sed -i 's/\s*./\U&\E/g' $@ filenamebut... (7 Replies)
Discussion started by: georgi58
7 Replies

4. What is on Your Mind?

Variations on a theme...

Well you lot seriously amaze me. There was a thread a few hours ago, (on the date stamp shown in this upload), that generated loads of solutions to a fairly simple problem:- https://www.unix.com/shell-programming-scripting/235829-how-print-particular-character-n-number-times-line.html As a... (0 Replies)
Discussion started by: wisecracker
0 Replies

5. Shell Programming and Scripting

Simple ways to pass variations to grep

can someone please show me a better way (if there is one), to grep out all variations (upper and small case letters) from a file? egrep "(panic|error|failed|fail|FAIL)" /var/log/messages I'm interested in finding any string that may indicate somethings wrong with ANY part of a system. so, if... (6 Replies)
Discussion started by: SkySmart
6 Replies

6. Shell Programming and Scripting

script to include filename with variations at the beginning of the file

Hi there, I have a bunch of files that I want to modify. As a beginner, but nevertheless enthusiast, in the use of the shell I want to create a script enabling me to modify those files quickly. I had only some partial success with various peaces of scripts but I would like to create one script... (1 Reply)
Discussion started by: iamzesh
1 Replies

7. Shell Programming and Scripting

Convert to upper case first letter of each word in column 2

Hi guys, I have a file separated by ",". I´m trying to change to upper case the first letter of each word in column 2 to establish a standard format on this column. I hope somebody could help me to complete the SED or AWK script below. The file looks like this: (Some lines in column 2... (16 Replies)
Discussion started by: cgkmal
16 Replies

8. Shell Programming and Scripting

Convert first character of each word to upper case

Hi, Is there any function(Bash) out there that can convert the first character of each word to upper case?... (3 Replies)
Discussion started by: harchew
3 Replies

9. UNIX for Dummies Questions & Answers

printing only the middle word between two patterns

How would I print the word "and" between the words "FOO" and BAR" using sed? My file has three words in it FOO and BAR. I only want the word "and". Thanks every one. (7 Replies)
Discussion started by: tigta09
7 Replies

10. Shell Programming and Scripting

Printing 1st column to lower case using awk

I want to print the 1st field in a comma seperated file to lower case and the rest the case they are. I tried this nawk -F"," '{print tolower($0)}' OFS="," file this converts whole line in to lower case i just want the first column to be converted. The below doesnt work because in... (11 Replies)
Discussion started by: pinnacle
11 Replies
Login or Register to Ask a Question