Re: Grep For Line Containing 1or 2 Words

From: drwxr-xr-x (bit-bucket_at_config.com)
Date: 01/30/05


Date: 30 Jan 2005 00:07:58 GMT

On Tue, 25 Jan 2005 22:40:59 GMT, noi wrote:
> On Tue, 25 Jan 2005 16:47:23 -0500, Buck Turgidson thoughtfully wrote:
>
>> Looking for help in writing a grep (or perl) that will pull from a text
>> file those lines containing one or two "words". I want to reject any line
>> that contains more than 2 words (a sentence).
>>
>> Appreciate any help from text processing experts.
>
> Would this work for you? (Assumed text file)
> $ cat file | grep -v --regexp=" " > nospaces

No, it would not.

  $ cat text.tmp
  aertyu
  bdfgh tyui
  cdfghj cvbn dfghjkl
  dwert uiop mnbv hgfds
  $ grep -v --regexp=" " > text.new < text.tmp
  $ cat text.new
  aertyu
  $

... and, where's that guy handing out this week's UUOCA?



Relevant Pages

  • Re: Dumb printing question
    ... If you want to split the output and both drive the printer and save a file copy then look at the jetdirectprint script.. ... # cat jetdirectprint ... open a socket to the printer. ... My PERL is nonexistent, so don't ask me for syntactically correct PERL. ...
    (comp.os.linux.misc)
  • RE: sourcing one perl file from another
    ... There are some ways to 'source' a config file like under unix shell. ... $ cat usedata.pl ... I've a perl program, and I'm trying to make it tidier. ...
    (perl.beginners)
  • Re: Progress Topic 3.1
    ... we've now gotten XT-002 down, Ignis the Furnace Master down, The Iron ... to get Iron Council, Ignis, Kologarn, the cat lady and Hodir down. ... After the pull it too felt quite easy to heal. ...
    (alt.games.warcraft)
  • Re: shell script replacing original file
    ... of the original file:- ... Looks fine but using perl it is much simpler. ... % cat test.txt ...
    (comp.unix.shell)
  • Re: All Software Sucks at the worst possible time.
    ... I'm sure some poor sod was caused great pain by that, ... I tend to pull apart the stuff in my personal museum, ... You see, wire telegraph is a kind of a very, very long cat. ... And radio operates exactly the same way: ...
    (alt.sysadmin.recovery)