LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-04-2011, 01:16 PM   #1
LennyOO
LQ Newbie
 
Registered: Oct 2011
Posts: 1

Rep: Reputation: Disabled
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.
 
Old 10-04-2011, 02:53 PM   #2
Ian John Locke II
Member
 
Registered: Mar 2008
Location: /dev/null
Distribution: Slackware, Android, Slackware64
Posts: 130

Rep: Reputation: 17
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.
 
1 members found this post helpful.
Old 10-05-2011, 05:36 AM   #3
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,253

Rep: Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686
Quote:
And PLEASE do not bug me with "man grep" or "man sed" or w/e because those descriptions are too plain to help
As you are at school I won't bug you with any of the above and simply say ... ask your teacher.
 
1 members found this post helpful.
Old 10-05-2011, 10:04 AM   #4
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
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.
 
2 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] awk and sed questions rock1961 Programming 7 08-03-2011 10:06 AM
awk or sed to for this questions solution ? cs24 Programming 7 03-20-2010 06:23 AM
sed questions UltraSoul Solaris / OpenSolaris 3 01-22-2008 05:32 AM
BASH array / sed questions ParaDoX667 Programming 8 04-04-2007 06:12 AM
sed questions slack66 Linux - Newbie 6 04-29-2006 11:24 AM


All times are GMT -5. The time now is 10:52 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration