I want to list all the executable files in the cwd using grep, and I used the following:
ls -F -a | grep "[*]$"
And it works, but why doesn’t the following command work? It should be equivalent:
ls -F -a | grep -E "[*]\>"
Oddly enough, if I use a standard character as ending letter (like grep -E “[a]>”) it works just fine
This won’t do what you are expecting because
*is not a “word” character and looking for an end-of-word boundary immediately after it makes no sense.Will yield all lines ending with
*as specified. This makes sense.You should heed @Adam’s advice: You should not parse the output of
ls.