Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Command Line Fundamentals

You're reading from   Command Line Fundamentals Learn to use the Unix command-line tools and Bash shell scripting

Arrow left icon
Product type Paperback
Published in Dec 2018
Publisher
ISBN-13 9781789807769
Length 314 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Vivek Nagarajan Vivek Nagarajan
Author Profile Icon Vivek Nagarajan
Vivek Nagarajan
Arrow right icon
View More author details
Toc

Chapter 3: Advanced Command-Line Concepts

Activity 8: Word Matching with Regular Expressions

The commands to be used to answer the questions can be found here:

  1. The following command can be used to find the number of words that are five letters in length, begin with a consonant, and contain alternating vowels and consonants:
    grep -c -E '^([^aeiou][aeiou]){2}[^aeiou]$' <words.txt
    506
  2. Use the following command to find the number of words that are two or more characters long, begin with a consonant, and contain alternating consonants and vowels:
    grep -c -E '^([^aeiou][aeiou])+[^aeiou]?$' <words.txt
    2339
  3. Use the following command to count the three-letter words that start and end with the same letter:
    grep -c -E '^(.).\1$' <words.txt
    23
  4. The following command can be used to find the number of words that have the same vowel repeating twice consecutively in it:
    grep -c -E '([aeiou])\1' <words.txt
    1097 
  5. The following...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at ₹800/month. Cancel anytime