in reply to grep or perl

Update: now uses -L (not -v) as that'll do the right thing (thanks to nite_man)
# use -r if you want to process recursively grep -L 'N\+' your_directory | xargs cp --target-directory wherever
Or a not-quite-one-liner in perl
perl -MFile::Find::Rule -le 'print for find(file => grep => qr/(?!N\+)/, in => @ARGV)' sourcedir | xargs \ cp --target-directory wherever
They're untested and assume *nix-esque command-line tools (which should be fine since you're running linux) but that should get you started.
HTH

_________
broquaint

Replies are listed 'Best First'.
Re: Re: grep or perl
by Anonymous Monk on Jun 04, 2003 at 13:00 UTC
    Many thanks for your suggestion and time. The grep --help command shows the following:
    -v, --invert-match select non-matching lines
    I wish to copy files that do not contain NNNNNs. I am not doing it on a line by line basis. Also I don't understand what the program xargs does also xargs --help does not tell me much.
      I wish to copy files that do not contain NNNNNs.
      Ah yes, sorry you'll want the -L switch as nite_man mentioned. That will output all the files that did not match the criteria.
      Also I don't understand what the program xargs does
      It's roughly equivalent to
      perl -e 'exec "@ARGV " . join " ", <>'
      So execute the given program and provided parameters and then add anything read from the pipe as arguments.
      HTH

      _________
      broquaint

        It's roughly equivalent to

        perl -e 'exec "@ARGV " . join " ", <>'

        So execute the given program and provided parameters and then add anything read from the pipe as arguments.

        This is true, but it might also be useful to note that xargs breaks the command line up into chunks small enough to fit on one command. For example, if you tried passing 40,000 filenames as one big long command line, it wouldn't work. Instead you could echo the 40,000 filenames into xargs (or, more realistically, pipe the output from find or grep), which will break them up accordingly.

        As a fun test, try the following: echo `find /usr -type f` vs find /usr -type f | xargs echo