home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!ukma!darwin.sura.net!zaphod.mps.ohio-state.edu!usc!news!netlabs!lwall
- From: lwall@netlabs.com (Larry Wall)
- Newsgroups: comp.unix.questions
- Subject: Re: Erasing words with less than n letters
- Message-ID: <1992Nov5.183133.1471@netlabs.com>
- Date: 5 Nov 92 18:31:33 GMT
- References: <1992Nov4.180618.9183@inesc.pt> <1992Nov5.011854.25944@umbc3.umbc.edu>
- Sender: news@netlabs.com
- Organization: NetLabs, Inc.
- Lines: 44
- Nntp-Posting-Host: scalpel.netlabs.com
-
- In article <1992Nov5.011854.25944@umbc3.umbc.edu> rouben@math9.math.umbc.edu (Rouben Rostamian) writes:
- : In article <1992Nov4.180618.9183@inesc.pt> jota@iguana.inesc.pt writes:
- : > Is there a way of erasing the words with less than n letters
- : >using unix ? sed ? awk ? The words (in a dictionary) are sorted and
- : >one per line.
- :
- : To print input lines containing n or more characters:
- :
- : awk 'length($0) >= n { print }'
-
- Here it is in sed (using 9 for our "n" to avoid confusion with -n):
-
- sed -n '/.\{9\}/p'
-
- Of course, maybe you prefer grep:
-
- grep '.\{9\}'
-
- Or nroff:
-
- #!/bin/sh
-
- (
- cat <<-'END'
- .de TR
- 'di
- .pl 1000v
- .if \\n(dl/24>=9 .aa
- .ST
- ..
- .de ST
- .pl 1n
- 'di aa
- .nr .i 0
- .it 1 TR
- ..
- .nf
- .ST
- END
- cat ${1-"$@"}
- ) | nroff
-
- Larry Wall
- lwall@netlabs.com
-