Re: bash, grep, and regular expressions

From: Michael Marsh (michael.a.marsh_at_gmail.com)
Date: 02/18/05

  • Next message: Maurits van Rees: "Re: awstats: new cron job?"
    Date: Fri, 18 Feb 2005 13:22:57 -0500
    To: debian-user@lists.debian.org
    
    

    On Fri, 18 Feb 2005 09:56:29 -0800, Freddy Freeloader
    <fredddy@cableone.net> wrote:
    > ls -al | grep -e ^d | grep -e '\<[^.][a-z]'

    This is most likely matching the user and group names, which indeed do
    not start with a dot and most likely begin with lowercase letters.
    The date shouldn't match because it generally starts with a capital
    letter, so you can try changing "ls -al" to "ls -aln" to get numeric
    IDs, and see if this works.

    You might try
    ls -al | grep -e ^d | grep -e '\<[^.][^[:space:]]*$'
    which will force grep to look at the last word in the line.

    Note that this might have problems with filenames that contain spaces,
    and will have problems with symlinks.

    -- 
    Michael A. Marsh
    http://www.umiacs.umd.edu/~mmarsh
    -- 
    To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org 
    with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
    

  • Next message: Maurits van Rees: "Re: awstats: new cron job?"

    Relevant Pages

    • RE: What exactly is this simple regex doing?
      ... > the regex to be matching anything except ... > a dot. ... So substituting them should return only 1 or more dots. ...
      (perl.beginners)
    • Re: Regex Question
      ... > and other combination but still failed.What it the problem with my pattern? ... the matching part would be 20030814/SDV.ZZ002_1. ... Add the dmp at the end of the regexp, so that the dmp is including ... Put the dot outside the second parenthesis group, ...
      (comp.unix.shell)