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
01-29-2011, 02:01 PM
Willie Wong
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
01-29-2011, 02:08 PM
Etaoin Shrdlu
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
01-29-2011, 02:17 PM
Petri Rosenström
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
01-29-2011, 02:22 PM
Florian Philipp
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,}'
01-29-2011, 02:41 PM
Willie Wong
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