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

Re: bash, grep, and regular expressions



Todd A. Jacobs wrote:
On Thu, Feb 17, 2005 at 04:08:49PM -0800, Freddy Freeloader wrote:


Now before you flame me this is done strictly as an exercise in
regular expressions.


The problem is that you're trying to handle too much at once. If you
simplify the problem by ONLY dealing with the filename:

    ls -a1 | egrep -v '^\.'

works fine. Note that the flag to ls is a one, not a lowercase L in this
instance.
If you want to parse the whole long-out format the hard way, you need to
match after the time field, so:

    ls -la | egrep ':[[:digit:]]{2} [^.]'

It works for me. YMMV.


I appreciate your input but neither one of the expressions filter anything on my machines. They both return sets that include everything, hidden and not hidden. This is the same problem I've had with everything else I've tried, and I've spent a lot of time on this. I know it's trivial but for some reason in the long format on my machines I can't write an expression that parses the beginning of the filename column.

What kernel and what version of bash are you using?



Reply to: