How to find vowel's occurence in a string


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to find vowel's occurence in a string
# 1  
Old 09-03-2007
MySQL How to find vowel's occurence in a string

Hi All,

I want to search the string for vowel's occurence and find the no of occurence of each vowels, Could anyone help me out? This is urgent to me...I m new to Shell programming..

Thanks and Regards,
NidsSmilie
# 2  
Old 09-03-2007
Quote:
Originally Posted by Nidhi2177
I want to search the string for vowel's occurence and find the no of occurence of each vowels,

Code:
string=qwertyuiopaasdisiaiweryuyiyotp
printf "%s\n" "$string" | awk '
BEGIN { split("a e i o u",a," ") } 
{
  tolower($0)

  for ( v in a ) {
    n=$0
    gsub( "[^"a[v]"]","",n)
    print a[v],length(n)
  }
}
'

# 3  
Old 09-03-2007
Code:
echo "stringishere" | awk 'BEGIN{FS=""}
 {
	for (i=1;i<=NF;i++ ) {
		if(tolower($i) ~ /a|e|i|o|u/ ){
			arr[$i]++
		}
	}
 }
 END{
	for ( i in arr ){
		print arr[i] , i
	}
 }
'

# 4  
Old 09-04-2007
Please do use the search feature of the forum. You would have found - https://www.unix.com/shell-programmin...of-vowels.html
# 5  
Old 09-06-2007
Thank u all, I have got the solutions..
Regards,
Nidhi
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Get nth occurence of string from a file

I have file in which the data looks like this, 01,0000000,xxxxxxx/ 02,xxxxxxxx,yyyyyy/ 03,test1,41203016,,/ 01,0000000,xxxxxxx/ 02,xxxxxxxx,yyyyyy/ ... (16 Replies)
Discussion started by: r@v!7*7@
16 Replies

2. Shell Programming and Scripting

Find and increment at each occurence of string (loop)

I created script (sh shell) to generate vlc playlist based on some data files. All works fine so far except one string I do not know how to handle with. VLCSTART='<vlc:id>' VLCV=0 VLCEND='</vlc:id>' echo -e $'\n'$'\t'$'\t'$'\t'$'\t'\$VLCSTART$VLCV$VLCENDOutput file contains several occurences... (10 Replies)
Discussion started by: TiedCone
10 Replies

3. Shell Programming and Scripting

Find the occurence of particular string in log file

I have a log file which looks like this: <845185415165:STATUS:5/0:0:0:0:0|ghy59DI5zasldf87asdfamas8df9asd903tGUVSQx4GJVSQ==> I have to extract DATE and number of times the keyword STATUS is shown on each date. Input is : <1354625655744:STATUS:5/0:0:0:0:0|ghy59DI5ztGUVSQx4GJVSQ==>... (8 Replies)
Discussion started by: maddyrox
8 Replies

4. UNIX for Dummies Questions & Answers

View 5 lines after the last occurence of a string

Hi Everyone, I am looking for the unix command by which I can view 5 lines after the last occurence of a string (including the last occurence) Example : I have the following lines in a unix file. I have to look for the last occurence of the string "How are you" and then view the next 5... (5 Replies)
Discussion started by: kannanfile
5 Replies

5. UNIX for Dummies Questions & Answers

To find the Nth Occurence of Search String

Hi guys, I like to find the Line number of Nth Occurence of a Search string in a file. If possible, if it will land the cursor to that particualar line will be great. Cheers!! (3 Replies)
Discussion started by: mac4rfree
3 Replies

6. Shell Programming and Scripting

shell script to find the second occurence of the alphabet in a string

this is my assignment question. i'm supposed to submit it tommorow. can somebody please help me with it? Do not post homework questions in the main forums. Please post in the homework forum using the correct template. (0 Replies)
Discussion started by: vijjy
0 Replies

7. Shell Programming and Scripting

Extract a string up to the first occurence of a substring

Hi, I'm a newbie to shell scripting and have searched the forum but couldn't find what i was looking for. Basically I have a list of filenames like... 123-fileone.txt I want to be able to extract the prefix up to the first '-'. So I'd end up with 123. I have attempted it using a pretty... (2 Replies)
Discussion started by: kirkg
2 Replies

8. Shell Programming and Scripting

Find index of last occurence of a character within a string

I need to find the index of last '|' (highlighted in bold) in awk : |ifOraDatabase.Lastservererr<>0then|iferr_flag<>0then|end if Please suggest a way... Thanks (5 Replies)
Discussion started by: joyan321
5 Replies

9. Shell Programming and Scripting

Greping a string for only one occurence

Hi, I have a csv ( comma seperated value) file and I want to search for a particular string in each line of that file only if it occurs only once in the line. That is same string may be present more than once in a line but I want it to be greped only when it occurs just once. Please advice... (17 Replies)
Discussion started by: Piscian
17 Replies

10. Shell Programming and Scripting

Replace string B depending on occurence of string A

Depending upon the occurence of string 'xyz', I want to remove -t from the input file. There is not a fixed length input file. Any suggestions Input file: this is xyz line -t of the data this is line 2 of -t of the data xyz this is line 3 of -t the file this is line xyz of the -t file... (1 Reply)
Discussion started by: hemangjani
1 Replies
Login or Register to Ask a Question