GNU bug report logs -
#24858
URGENT: Question about grep
Previous Next
Reported by: Greta <romano.greta <at> gmail.com>
Date: Wed, 2 Nov 2016 15:35:02 UTC
Severity: normal
Tags: notabug
Done: Eric Blake <eblake <at> redhat.com>
Bug is archived. No further changes may be made.
Full log
Message #24 received at 24858 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On 11/02/2016 12:24 PM, Paul Jackson wrote:
> Greta asked:
>>> So what I have to add in grep command to put the limit of 30 characters?
>
> Eric replied:
>>> You can't do it with grep.
>
> Bruce suggested:
>>> cut -c 30 filename | grep ACGTAC
>
> Using the following grep command seems to work for me, and is about
> 40% faster, in terms of user CPU time spent, on my system, using a large
> dataset I have (some web server logs) than using cut and grep in a pipeline,
> as the extra CPU cost of the more complex grep expression is more than
> compensated for by the reduced copying of the datastream:
>
> grep -E '^.{0,30}GTGTCA
That searches up to 36 characters. If you want to limit it to just the
first 30, you need '^.{0,24}GTGTCA', since the match will never occur
later than the 24th character of the first 30.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[signature.asc (application/pgp-signature, attachment)]
This bug report was last modified 8 years and 254 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.