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

Re: bash, grep, and regular expressions



Todd A. Jacobs wrote:
On Fri, Feb 18, 2005 at 03:58:42AM -0800, Freddy Freeloader wrote:


I appreciate your input but neither one of the expressions filter
anything on my machines.  They both return sets that include


Then you're obviously having problems with your pipes and/or shell
quoting. This works fine with 2.05b. If I were you, I'd use "set -x -v"
to see what's going on, as well as finding out if you have any weird
shopt options set.

You might also want to look at your aliases, and find out if you've done
something weird there. You can also run bash with the --norc and
--noprofile flags, to ensure that you're starting with a clean slate.
You might even want to try using a different account that hasn't been
futzed with, to see if you still have problems.

Since it works for everyone *but* you, the problem is neither regular
expressions nor bash, per se. It's something to do with your
configuration. So approach it as a debugging exercise, and investigate
accordingly.

Ding, Ding, Ding....

We have a winner ladies and gentlemen. It's the aliasing of ls to ls -al that screws it up. Don't ask me how, but it does. The following expression works perfectly after removing the alias.

ls -al | grep -e [0-9][0-9]:[0-9][0-9] [.]'

This returns only hidden files and folders.

ls -al | grep -e [0-9][0-9]:[0-9][0-9] [.]'

This returns only files and folders that are not hidden.

These expressions would not work when ls was aliased to ls -al nor if the full time column was not used.

Thank you very much for your help. It's the type of stuff only experience can teach me.

I would also like to say thank you to all the rest of you who gave me suggestions. I appreciate all your time and effort. I guess we all learned something on this one.



Reply to: