Issue
I've been struggling with this grep command:
ls data | grep -E "^[aeiou].*[aeiou]$"
The command is supposed to find all files that begin and end with a lowercase vowel
To my understanding, there doesnt need to be any escape character when using the -E identifier so it doesn't get interpreted as an anchor. I have this command listed under a target in my Makefile and the $ continues to behave like an anchor.
Does anyone know what I'm missing here?
When attempting to use escape chars running the target would completely ignore the $ symbol and print without it. Running the target with the previously provided command gives this error:
ls data | grep -E "^[aeiou].*[aeiou]
/bin/sh: 1: Syntax error: Unterminated quoted string
make: *** [Makefile:11: p3] Error 2
When adding an additional quote, I had the same problem above where it would ignore the $ symbol
Solution
If you're writing a makefile rule please include the actual rule in your question. Behavior of scripts at the command line vs. a recipe in a makefile are not 100% identical.
If you want the shell to receive a $
and you are writing a makefile recipe, you have to escape it because $
is special to make. Write:
list:
ls data | grep -E '^[aeiou].*[aeiou]$$'
Note the $$
here instead of $
.
Answered By - MadScientist Answer Checked By - Willingham (WPSolving Volunteer)