Gentoo Archives: gentoo-user

From: "Petri Rosenström" <petri.rosenstrom@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] [OT] find lines in text file by length
Date: Sat, 29 Jan 2011 15:20:46
Message-Id: AANLkTikiPj4JT9VXLetQ6Mk7VKS3KpON62RQmLeccrtX@mail.gmail.com
In Reply to: [gentoo-user] [OT] find lines in text file by length by Willie Wong
1 On Sat, Jan 29, 2011 at 5:01 PM, Willie Wong <wwong@××××××××××××××.edu> wrote:
2 > This is way OT, but I hope someone here can give me a quick answer:
3 >
4 > I have a text-file. Individual lines of it run from 10 to several
5 > thousand characters in length. Is there a simple* command that allows
6 > me to only display the lines that are, say, at least 300 characters
7 > long?
8 >
9 > Thanks in advance,
10 >
11 > W
12 >
13 >
14 > * simple of course includes appropriate incantations of sed/awk/perl/etc
15 > --
16 > Willie W. Wong                                     wwong@××××××××××××××.edu
17 > Data aequatione quotcunque fluentes quantitae involvente fluxiones invenire
18 >         et vice versa   ~~~  I. Newton
19 >
20 >
21 Hi,
22
23 Try something like
24
25 sed '/\w\{300,\}/!d' file
26
27 This should give you lines that have more than 300 word like
28 characters. If you put number after "," you may define the max number.
29 and you can change \w to match your needs => . .
30
31 Best regards
32 Petri