On Fri, Feb 18, 2005 at 04:12:16AM -0800, Freddy Freeloader wrote:
> Kevin Mark wrote:
> >On Thu, Feb 17, 2005 at 08:49:41PM -0800, Freddy Freeloader wrote:
> >
> >>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.
> >>
> >>
> >
> >Hi Freddy,
> >find -maxdepth 1 |grep -v "^\./\."
> >(remove files that start with ./.)
> >this find files and directories in the current directory that are not
> >hidden. Hidden files and directories start with .
> >Cheers,
> >Kev
>
> Hi Kevin,
>
> This returns the correct files ok. However, it's not too much different
> than ls -a | grep -v '^\.' which I can make work too. What I'm really
> trying to do is figure out how to parse the beginning of the file name
> column in the long format, and I just can't come up with a way to do
> that on my machines. I've been given expressions that do it on other
> machines, but I have yet to find one that will work on my machines.
>
> I just can't see why grep can't recognize the beginning of the word in
> the file name column in the long format. Why will it recognize the . in
> short format at the beginning of a line, but not in the long format at
> the beginning of a word? I can parse the beginning of words in any
> other situation I've come across but not in in ls -al.
Hi Freddy,
ls -a just returns the file names and thus the first column will contain
the start of the filename. ls -al show the permission in the first
column and thus the "^..." will be matched against it and not the
filename.
-Kev
--
counter.li.org #238656 -- goto counter.li.org and be counted!
(__)
(oo)
/------\/
/ | ||
* /\---/\
~~ ~~
...."Have you mooed today?"...
Attachment:
signature.asc
Description: Digital signature