FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Gentoo > Gentoo User

 
 
LinkBack Thread Tools
 
Old 01-29-2011, 01:57 PM
Etaoin Shrdlu
 
Default find lines in text file by length

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
 
Old 01-29-2011, 02:01 PM
Willie Wong
 
Default find lines in text file by length

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
 
Old 01-29-2011, 02:08 PM
Etaoin Shrdlu
 
Default find lines in text file by length

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
 
Old 01-29-2011, 02:17 PM
Petri Rosenström
 
Default find lines in text file by length

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
 
Old 01-29-2011, 02:22 PM
Florian Philipp
 
Default find lines in text file by length

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,}'
 
Old 01-29-2011, 02:41 PM
Willie Wong
 
Default find lines in text file by length

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
 

Thread Tools




All times are GMT. The time now is 01:33 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2007 - 2008, www.linux-archive.org