Linux - NewbieThis 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

Welcome to LinuxQuestions.org, a friendly and active Linux Community.

You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!

Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.

If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.

Having a problem logging in? Please visit this page to clear all LQ-related cookies.

Introduction to Linux - A Hands on Guide

This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.

I'm trying to look at a file and find 6 or more consecutive consonants (everything except a vowel). However I have a hidden $ character at the end of each line in the file. For some reason I can't reference to it in any of the pattern searching commands.

For example: grep '[^aeiouAEIOU$]\{6,\}' file| more

This command returns words that contain 5 consonants at the end (because it interprets the hidden $ as not a vowel). How can I make it ignore the hidden character? Or more specifically how do I refer to the hidden character in my pattern searches?

I think maybe you need to understand regular expressions a little bit more. The "hidden character", the dollar-sign, is not really there. In regular expressions, the dollar-sign indicates "end of the line" when making a match.
So, for example, if I use in a regex:

hello$

the regex would match a line where the word "hello" is the last word(characters) on the line. If I omit the "$" then the word "hello" can be matched anywhere in the line.

You see the match made in red text in the first case, because there is no "$" given in the grep regex. Therefore the match of 6-straight non-vowels can happen anywhere in the line.
In the second example, I have added a "$". Therefore there is no match, because there is a vowel at the end of the line, but my regex specifies that the run of consonants must be at the end of the line.

I hope this clarifies the issue of the hidden "$"

P.S. - I think there's still something wrong with the regex though - it doesn't match the vowels/consonants correctly for me.-
EDIT - sorry, I had a typo!

I think maybe you need to understand regular expressions a little bit more. The "hidden character", the dollar-sign, is not really there. In regular expressions, the dollar-sign indicates "end of the line" when making a match.
So, for example, if I use in a regex:

hello$

the regex would match a line where the word "hello" is the last word(characters) on the line. If I omit the "$" then the word "hello" can be matched anywhere in the line.

You see the match made in red text in the first case, because there is no "$" given in the grep regex. Therefore the match of 6-straight non-vowels can happen anywhere in the line.
In the second example, I have added a "$". Therefore there is no match, because there is a vowel at the end of the line, but my regex specifies that the run of consonants must be at the end of the line.

I hope this clarifies the issue of the hidden "$"

P.S. - I think there's still something wrong with the regex though - it doesn't match the vowels/consonants correctly for me.-
EDIT - sorry, I had a typo!

I understand this, but it doesn't really help me much. I want the 6 consecutive consonants to be ANYWHERE not just at the end of the line. If grep ignored the hidden characters I would not see the words with 5 consecutive consonants at the end of a line (because the pattern is looking for 6 not 5). That's why I assumed that grep was reading the hidden $ and considering it as a consonant, thus returning words that had 5 consecutive consonants at the end of a line.

You want to match 6 consecutive consonants, as shown above in example one. The 6 consonants are somewhere in the middle of the line. The second example only has 5 consonants, so is not matched.

Grep pays attention to any characters you tell it to pay attention to. However in this case, the "$" is not a character. It is merely a signifier of the "end of a line". If you don't care where in a line the match occurs, do not use a $. If you want the match to be at the end of the line only, then end your regex with a $.