* Re: [gentoo-user] [OT] find lines in text file by length
2011-01-29 15:01 [gentoo-user] [OT] find lines in text file by length Willie Wong
@ 2011-01-29 14:57 ` Etaoin Shrdlu
2011-01-29 15:08 ` Etaoin Shrdlu
2011-01-29 15:17 ` Petri Rosenström
2011-01-29 15:22 ` Florian Philipp
2 siblings, 1 reply; 6+ messages in thread
From: Etaoin Shrdlu @ 2011-01-29 14:57 UTC (permalink / raw
To: gentoo-user
On Sat, 29 Jan 2011 10:01:02 -0500
Willie Wong <wwong@Math.Princeton.EDU> wrote:
> This is way OT, but I hope someone here can give me a quick answer:
>
> I have a text-file. Individual lines of it run from 10 to several
> thousand characters in length. Is there a simple* command that allows
> me to only display the lines that are, say, at least 300 characters
> long?
awk 'length >= 300' file
sed -n '/.\{300\}/p' file
^ permalink raw reply [flat|nested] 6+ messages in thread
* [gentoo-user] [OT] find lines in text file by length
@ 2011-01-29 15:01 Willie Wong
2011-01-29 14:57 ` Etaoin Shrdlu
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Willie Wong @ 2011-01-29 15:01 UTC (permalink / raw
To: gentoo-user
This is way OT, but I hope someone here can give me a quick answer:
I have a text-file. Individual lines of it run from 10 to several
thousand characters in length. Is there a simple* command that allows
me to only display the lines that are, say, at least 300 characters
long?
Thanks in advance,
W
* simple of course includes appropriate incantations of sed/awk/perl/etc
--
Willie W. Wong wwong@math.princeton.edu
Data aequatione quotcunque fluentes quantitae involvente fluxiones invenire
et vice versa ~~~ I. Newton
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [gentoo-user] [OT] find lines in text file by length
2011-01-29 14:57 ` Etaoin Shrdlu
@ 2011-01-29 15:08 ` Etaoin Shrdlu
2011-01-29 15:41 ` Willie Wong
0 siblings, 1 reply; 6+ messages in thread
From: Etaoin Shrdlu @ 2011-01-29 15:08 UTC (permalink / raw
To: gentoo-user
On Sat, 29 Jan 2011 14:57:28 +0000
Etaoin Shrdlu <shrdlu@unlimitedmail.org> wrote:
> On Sat, 29 Jan 2011 10:01:02 -0500
> Willie Wong <wwong@Math.Princeton.EDU> wrote:
>
> > This is way OT, but I hope someone here can give me a quick answer:
> >
> > I have a text-file. Individual lines of it run from 10 to several
> > thousand characters in length. Is there a simple* command that allows
> > me to only display the lines that are, say, at least 300 characters
> > long?
>
> awk 'length >= 300' file
>
> sed -n '/.\{300\}/p' file
Oh, and obviously
grep '.\{300\}' file
perl -ne 'print if /.{300}/' file
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [gentoo-user] [OT] find lines in text file by length
2011-01-29 15:01 [gentoo-user] [OT] find lines in text file by length Willie Wong
2011-01-29 14:57 ` Etaoin Shrdlu
@ 2011-01-29 15:17 ` Petri Rosenström
2011-01-29 15:22 ` Florian Philipp
2 siblings, 0 replies; 6+ messages in thread
From: Petri Rosenström @ 2011-01-29 15:17 UTC (permalink / raw
To: gentoo-user
On Sat, Jan 29, 2011 at 5:01 PM, Willie Wong <wwong@math.princeton.edu> wrote:
> This is way OT, but I hope someone here can give me a quick answer:
>
> I have a text-file. Individual lines of it run from 10 to several
> thousand characters in length. Is there a simple* command that allows
> me to only display the lines that are, say, at least 300 characters
> long?
>
> Thanks in advance,
>
> W
>
>
> * simple of course includes appropriate incantations of sed/awk/perl/etc
> --
> Willie W. Wong wwong@math.princeton.edu
> Data aequatione quotcunque fluentes quantitae involvente fluxiones invenire
> et vice versa ~~~ I. Newton
>
>
Hi,
Try something like
sed '/\w\{300,\}/!d' file
This should give you lines that have more than 300 word like
characters. If you put number after "," you may define the max number.
and you can change \w to match your needs => . .
Best regards
Petri
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [gentoo-user] [OT] find lines in text file by length
2011-01-29 15:01 [gentoo-user] [OT] find lines in text file by length Willie Wong
2011-01-29 14:57 ` Etaoin Shrdlu
2011-01-29 15:17 ` Petri Rosenström
@ 2011-01-29 15:22 ` Florian Philipp
2 siblings, 0 replies; 6+ messages in thread
From: Florian Philipp @ 2011-01-29 15:22 UTC (permalink / raw
To: gentoo-user
[-- Attachment #1: Type: text/plain, Size: 481 bytes --]
Am 29.01.2011 16:01, schrieb Willie Wong:
> This is way OT, but I hope someone here can give me a quick answer:
>
> I have a text-file. Individual lines of it run from 10 to several
> thousand characters in length. Is there a simple* command that allows
> me to only display the lines that are, say, at least 300 characters
> long?
>
> Thanks in advance,
>
> W
>
>
> * simple of course includes appropriate incantations of sed/awk/perl/etc
egrep '.{300,}'
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [gentoo-user] [OT] find lines in text file by length
2011-01-29 15:08 ` Etaoin Shrdlu
@ 2011-01-29 15:41 ` Willie Wong
0 siblings, 0 replies; 6+ messages in thread
From: Willie Wong @ 2011-01-29 15:41 UTC (permalink / raw
To: gentoo-user
On Sat, Jan 29, 2011 at 03:08:11PM +0000, Etaoin Shrdlu wrote:
> Oh, and obviously
>
> grep '.\{300\}' file
>
D'Oh! That's really obvious. Thanks!
W
--
Willie W. Wong wwong@math.princeton.edu
Data aequatione quotcunque fluentes quantitae involvente fluxiones invenire
et vice versa ~~~ I. Newton
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-01-29 15:42 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-29 15:01 [gentoo-user] [OT] find lines in text file by length Willie Wong
2011-01-29 14:57 ` Etaoin Shrdlu
2011-01-29 15:08 ` Etaoin Shrdlu
2011-01-29 15:41 ` Willie Wong
2011-01-29 15:17 ` Petri Rosenström
2011-01-29 15:22 ` Florian Philipp
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox