Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please build a patter using grep for the following 2. The next puzzle is an old

ID: 3705787 • Letter: P

Question

Please build a patter using grep for the following

2. The next puzzle is an old one. Find a common English word that contains all five vowels – a, e, i, o, u – in that order. The letters do not have to be adjacent, but they must be in alphabetical order. That is, “a” must come before “e”, which must come before “i”, and so on.

3. Our last puzzle involves a search of the Unix file system for historical artifacts. Many of the original Unix commands were two letters long; the text editor was ed, the copy program was cp, and so on. Let us find all such commands. To solve the puzzle, you need to know that the very oldest Unix programs reside in the /bin directory. There are other old Unix command in /usr/bin. Be sure to also provide a count of how many such commands there are.


Note: when you look in the /usr/bin, you may find some 2-character commands that are not old. To see if a command dates from the early days of Unix, check its man page. But you need not to implement this in your Regex.

Explanation / Answer

NOTE: I have completed your assignment. Please check and let me know if you find any issues. I will revert back within 24 hours. thanks for your patience.


2)
Command Snapshot:
Unix Terminal> cat /tmp/file
hi hello world
facetiously is a word with all vowels
abstemious is another word
hello these are specific examples
some funky word bstemious to test

Unix Terminal> cat /tmp/file|grep -E 'a.*e.*i.*o.*u'
facetiously is a word with all vowels
abstemious is another word
Unix Terminal>

Explanation:
1) /tmp/file is the sample file created for testing the command
2) cat /tmp/file displays file contents and it is streamed to grep through pipe command
3) -E enables regular expressions in grep. The pattern 'a.*e.*i.*o.*u' indicates vowels followed in any sequence but not necessarily next to each other.
4) cat /tmp/file|grep -E 'a.*e.*i.*o.*u'
the command will display all lines containing words which have vowels in alphabetical sequence

3)
Command snapshot:
Unix Terminal> ls /usr/bin|grep -E '^[a-z][a-z]$'
ar
as
at
bc
bg
cc
cd
cu
dc
du
ex
fc
fg
id
ld
lp
nc
nl
nm
od
pl
pp
pr
ri
rs
su
tr
ul
vi
wc
Unix Terminal>
Unix Terminal> ls /usr/bin|grep -E '^[a-z][a-z]$'|wc -l
30

Explanation:
1) The pattern [a-z][a-z] matches two letter words
2) The pattern ^[a-z][a-z]$ matches only two letter words not more than that. The ^ represents beginning of the word and $ represents end of the word
3) If we want to get the count of such 2 letter command we can use wc -l command like above.