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

Re: bash, grep, and regular expressions





Freddy Freeloader wrote:

Adam Garside wrote:

On Fri, Feb 18, 2005 at 03:58:42AM -0800, Freddy Freeloader wrote:
[snip]

I can't write an expression that parses the beginning of the filename column.


How about:

ls -la | awk '$8 ~ /^[^.]/{print}'
which returns all non-hidden files and directories.

-- asg



I'm sorry to say, that it returns everthing. It's as if the output of ls -al is printed directly to the screen. Don't feel bad though this has happened to me every time I've tried something, and to everyone else too, and I've had 8 or 10 people give me examples that they say works on their machines.

That's why I'm here on this list. I can't figure this out. It's like there's a bug in this, but I'm not willing to write it off to that as yet because I don't have that much experience with regular expressions.


How about:

ls -la | awk '{ if (substr($9,0,1) != ".") {print $9}}'

-mike



Reply to: