in reply to Using grep to find "/<file system"

Many thanks for all the quick replies! I have got it to work using:

grep !/^(\/usr|\/sbin|\/platform|\/lib)$/, @files;

Best regards.

Replies are listed 'Best First'.
Re^2: Using grep to find "/<file system"
by johngg (Canon) on Oct 14, 2011 at 16:06 UTC

    A couple of points regarding the readability of your solution. By choosing a regex delimiter other than the standard '/' you would not have to escape the forward slashes, although you do have to explicitly use the 'm' match operator if not using forward slashes (or question marks, see Regexp Quote-Like Operators in perlop) as the delimiter. Also, the forward slash is common to all of the paths so you could move it out of the alternation. The code becomes

    grep ! m{^/(usr|sbin|platform|lib)$}, @files;

    which to my eye is somewhat clearer!

    I hope this helpful.

    Cheers,

    JohnGG

Re^2: Using grep to find "/<file system"
by pvaldes (Chaplain) on Oct 14, 2011 at 15:55 UTC
    mmh... I think this is a work for File:find or opendir/readdir...
Re^2: Using grep to find "/<file system"
by anneli (Pilgrim) on Oct 15, 2011 at 09:22 UTC