[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: bash, grep, and regular expressions



Glenn English wrote:
On Thu, 2005-02-17 at 16:08 -0800, Freddy Freeloader wrote:


What I've been attempting to do with grep and regular expressions is list only non-hidden directories and/or files. I am unable to come up with an expression that will elimate hidden files and return non-hidden files at the same time.

ls -al | grep -v ' \.\<[a-zA-Z0-9].*\>' # returns everything

ls | grep -e '\<[^.][[:alnum:]]'  # returns everything

ls | grep -e '\<[.][[:alnum:]]'  # returns an empty set



 ls -al | grep -v ' \.'   seems to work here???


I thought about this a little more and from it's behavior of filtering out files with extensions I'd say it's not filtering based on the . that designates whether a file or directory is hidden.

I have a few files without extensions and it returns those, but any file with an extension is filtered out. So, this isn't really resovling the problem I'm having.



Reply to: