Some questions concerning the 'sed' and 'tr' command.
Hello people! I am new to this forum. I've registered because I require some assistance with some commands. I'm on a school and I have to do assignments concerning text and stuff.
One of these assignments is : I have to find the most frequent words that only have one series of vowels (vowel = a/i/o/u/e right?) such as : for, fir, far are the "same" for this, and results such as "verify" that have two series of vowels, should not be output. I know I should first do a tokenisation process using " sed 's/\([.!?"(),:;]\)/ \1 /g' *.txt | tr -s ' ' '\n' | ", and then use a grep command to search for words that have a series of vowels, but no more than one. I thought of this: " grep -i ^[bcdfghjklmnpqrstvwx][aieouáéíóúàùìòè]+[bcdfghjklmnprqrstvwx]$ " . But no results. What is "wrong"? And can anyone help me with the rest? I am so clueless and desperate... I am not looking for straight answers, but I would like to understand it. Thank you in advance. :-) And PLEASE do not bug me with "man grep" or "man sed" or w/e because those descriptions are too plain to help someone with something like this. |
Unless you use the -E flag in grep, the + will be interpreted literally (i.e. as a '+' as opposed to the special character +). You should also be aware that + means 1 or more. If you want only one, you should use {1} to specify exactly how many you want.
I.e. foor would be matched in your pattern where as only for, fir and far would be matched with the {1}. If you leave out the -E flag, you can just escape the + symbol and the {}s Hope this helps. |
Quote:
|
I'd only like to add that the grep man page does provide the answer your question, or at least part of it. Read the section on basic vs. extended regular expressions. They apply to both grep and sed.
Don't forget also that there are info pages that go into more detail, as well as plenty of tutorials available on the web. I'll end by mentioning that sed alone has pretty much all of the function of grep and tr built-in; meaning that you should only very rarely need to use them in tandem. How about simply adding a newline to the sed replacement string, for example? Oh, and please use [code][/code] tags around your code, to preserve formatting and to improve readability. |
All times are GMT -5. The time now is 12:55 PM. |