X-Loop: help-debbugs@HIDDEN Subject: bug#28304: Feature Request - Quit on Non Match Resent-From: Adam Danischewski <adam.danischewski@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-grep@HIDDEN Resent-Date: Thu, 31 Aug 2017 14:44:02 +0000 Resent-Message-ID: <handler.28304.B.150419062118416 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: report 28304 X-GNU-PR-Package: grep X-GNU-PR-Keywords: To: 28304 <at> debbugs.gnu.org X-Debbugs-Original-To: bug-grep@HIDDEN Received: via spool by submit <at> debbugs.gnu.org id=B.150419062118416 (code B ref -1); Thu, 31 Aug 2017 14:44:02 +0000 Received: (at submit) by debbugs.gnu.org; 31 Aug 2017 14:43:41 +0000 Received: from localhost ([127.0.0.1]:37680 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1dnQh3-0004my-7h for submit <at> debbugs.gnu.org; Thu, 31 Aug 2017 10:43:41 -0400 Received: from eggs.gnu.org ([208.118.235.92]:58456) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <adam.danischewski@HIDDEN>) id 1dnQh2-0004mk-8v for submit <at> debbugs.gnu.org; Thu, 31 Aug 2017 10:43:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <adam.danischewski@HIDDEN>) id 1dnQgw-0006fc-6c for submit <at> debbugs.gnu.org; Thu, 31 Aug 2017 10:43:35 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=BAYES_40,FREEMAIL_FROM, HTML_MESSAGE,T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:38456) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from <adam.danischewski@HIDDEN>) id 1dnQgw-0006fU-3G for submit <at> debbugs.gnu.org; Thu, 31 Aug 2017 10:43:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49415) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <adam.danischewski@HIDDEN>) id 1dnQgu-0006Mu-U0 for bug-grep@HIDDEN; Thu, 31 Aug 2017 10:43:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <adam.danischewski@HIDDEN>) id 1dnQgu-0006ef-6B for bug-grep@HIDDEN; Thu, 31 Aug 2017 10:43:32 -0400 Received: from mail-qt0-x230.google.com ([2607:f8b0:400d:c0d::230]:33087) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from <adam.danischewski@HIDDEN>) id 1dnQgu-0006eK-2Z for bug-grep@HIDDEN; Thu, 31 Aug 2017 10:43:32 -0400 Received: by mail-qt0-x230.google.com with SMTP id e2so3884371qta.0 for <bug-grep@HIDDEN>; Thu, 31 Aug 2017 07:43:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=nSEyVEhZ6/9cSSp5wnLlrQZqnQ8c3t4y2CrXOmrgN4o=; b=gL8hspUpiR1bQldbgPhg1K6Mjqf7nFX6HBWfp8nU/Q4M8eWavs7jV3n8Nz8xoxHGm8 o7u0hSNQrrxBOpUPkC4zOyR8JgaNo03QwS9HgbOnMlcGarDlf0ZI3//BSr1Td3PLNnDB aoyGOiu/3kQPOybPEeFjIvkQMoTgYzlSW5AN0FuVl2myOCWskwflEN0Y9W+JdWHCwKHW sUPlBZQwjc7c3L6WivEEsC2QtmSKEZ+WToNv1TdWm/Q/xdHfO40kcxoIvBImt3T53sW4 1Ny34kPvoAL+V4TFwowYfGXqnNpUm/2fDmUgjzUc/NelJsjcqxuBSd2/4MXUata9SbuM v+Dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=nSEyVEhZ6/9cSSp5wnLlrQZqnQ8c3t4y2CrXOmrgN4o=; b=gMC9w2lAtDnya9qMr6/WFJXr8QVi11qAm9J+BoKQ3jZc/5IGV8tY+Ai6c8tJjHKjzx dpYl387ZtxN1jRrx7DJvlTWWEVBf+5g491BBUHSCfy79zcZUxAeFItei8+pI1i/i/GOB GwkaaGUAD8ywro1YY5m1a5nX9rCNEZNEqGzMiXdE23RuqPnFr6/fCE+SEBvH9p1FdJ2m AqIybkW5xyVbYM3K1KHNqcnXcqel1TU2Lmju8QtYBJe7quTHY75CUbZwIjzV/Sn8j6qE Vv+8b38Xd5DR5jytpAH8s+0uD3ngk8tq84W0usPGwC6zjIxE99dmBmkBFfuwRXAMGAwP 5ozw== X-Gm-Message-State: AHYfb5ivn55S/GQ3hkL6emOVoSAWJXo+gBQl2CJdsZ93ylbcTXPSYgn3 VzjMq2/uiq/k7KTH9OaFQwk5C/EBIXxl X-Google-Smtp-Source: ADKCNb51xLgA4lsAJ5+pUcmECASYfc58Aa75/WHy+lAzL65/Q13IHLVO627qoJLyG45lhGhpVFDkF32vIAgV2K/1xLo= X-Received: by 10.237.63.9 with SMTP id p9mr8209941qtf.109.1504190610440; Thu, 31 Aug 2017 07:43:30 -0700 (PDT) MIME-Version: 1.0 Received: by 10.12.154.5 with HTTP; Thu, 31 Aug 2017 07:43:30 -0700 (PDT) From: Adam Danischewski <adam.danischewski@HIDDEN> Date: Thu, 31 Aug 2017 10:43:30 -0400 Message-ID: <CAOQZJ0Hb7fsHjDrfGViRyQ742ux4qYPVf5Op74f5LWRVvWB4dA@HIDDEN> Content-Type: multipart/alternative; boundary="001a113d638c0287e705580dabed" X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -4.0 (----) --001a113d638c0287e705580dabed Content-Type: text/plain; charset="UTF-8" I've been writing parsers and it would be really nice if grep could do the following: *grep --quit-nm 1 -Pno "^[ \t\f]*#.*$" <(sed -n '2,$p' gen_ent.bsh)* If you: *grep -m 1 -Pno "^[ \t\f]*#.*$" <(sed -n '2,$p' gen_ent.bsh)* Only the first match of the header block gets printed, yet it would be nice if grep in O(n), could simply be on the look out for the first failure to match the -o context and quit at --quit-nm non-match occurrences. --001a113d638c0287e705580dabed Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr"><div><div><div>I've been writing parsers and it would = be really nice if grep could do the following: <br></div><div>=C2=A0<br></d= iv><b>grep --quit-nm 1 -Pno "^[ \t\f]*#.*$" <(sed -n '2,$p= ' gen_ent.bsh)</b><br><br></div>If you: <br><b>grep -m 1 -Pno "^[ = \t\f]*#.*$" <(sed -n '2,$p' gen_ent.bsh)</b><br><br></div>O= nly the first match of the header block gets printed, yet it would be nice = if grep in O(n), could simply be on the look out for the first failure to m= atch the -o context and quit at --quit-nm non-match occurrences. <br><br></= div> --001a113d638c0287e705580dabed--
Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) Content-Type: text/plain; charset=utf-8 X-Loop: help-debbugs@HIDDEN From: help-debbugs@HIDDEN (GNU bug Tracking System) To: Adam Danischewski <adam.danischewski@HIDDEN> Subject: bug#28304: Acknowledgement (Feature Request - Quit on Non Match) Message-ID: <handler.28304.B.150419062118416.ack <at> debbugs.gnu.org> References: <CAOQZJ0Hb7fsHjDrfGViRyQ742ux4qYPVf5Op74f5LWRVvWB4dA@HIDDEN> X-Gnu-PR-Message: ack 28304 X-Gnu-PR-Package: grep Reply-To: 28304 <at> debbugs.gnu.org Date: Thu, 31 Aug 2017 14:44:02 +0000 Thank you for filing a new bug report with debbugs.gnu.org. This is an automatically generated reply to let you know your message has been received. Your message is being forwarded to the package maintainers and other interested parties for their attention; they will reply in due course. Your message has been sent to the package maintainer(s): bug-grep@HIDDEN If you wish to submit further information on this problem, please send it to 28304 <at> debbugs.gnu.org. Please do not send mail to help-debbugs@HIDDEN unless you wish to report a problem with the Bug-tracking system. --=20 28304: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D28304 GNU Bug Tracking System Contact help-debbugs@HIDDEN with problems
X-Loop: help-debbugs@HIDDEN Subject: bug#28304: Feature Request - Quit on Non Match Resent-From: arnold@HIDDEN Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-grep@HIDDEN Resent-Date: Thu, 31 Aug 2017 14:54:02 +0000 Resent-Message-ID: <handler.28304.B28304.150419121319325 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 28304 X-GNU-PR-Package: grep X-GNU-PR-Keywords: To: adam.danischewski@HIDDEN, 28304 <at> debbugs.gnu.org Received: via spool by 28304-submit <at> debbugs.gnu.org id=B28304.150419121319325 (code B ref 28304); Thu, 31 Aug 2017 14:54:02 +0000 Received: (at 28304) by debbugs.gnu.org; 31 Aug 2017 14:53:33 +0000 Received: from localhost ([127.0.0.1]:37698 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1dnQqb-00051d-79 for submit <at> debbugs.gnu.org; Thu, 31 Aug 2017 10:53:33 -0400 Received: from freefriends.org ([96.88.95.60]:55058) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <arnold@HIDDEN>) id 1dnQqZ-00051V-Hl for 28304 <at> debbugs.gnu.org; Thu, 31 Aug 2017 10:53:31 -0400 X-Envelope-From: arnold@HIDDEN Received: from freefriends.org (localhost [127.0.0.1]) by freefriends.org (8.14.9/8.14.9) with ESMTP id v7VErUFX024121; Thu, 31 Aug 2017 08:53:30 -0600 Received: (from arnold@localhost) by freefriends.org (8.14.9/8.14.9/submit) id v7VErUtT024120; Thu, 31 Aug 2017 14:53:30 GMT From: arnold@HIDDEN Message-Id: <201708311453.v7VErUtT024120@HIDDEN> X-Authentication-Warning: frenzy.freefriends.org: arnold set sender to arnold@HIDDEN using -f Date: Thu, 31 Aug 2017 08:53:30 -0600 References: <CAOQZJ0Hb7fsHjDrfGViRyQ742ux4qYPVf5Op74f5LWRVvWB4dA@HIDDEN> In-Reply-To: <CAOQZJ0Hb7fsHjDrfGViRyQ742ux4qYPVf5Op74f5LWRVvWB4dA@HIDDEN> User-Agent: Heirloom mailx 12.4 7/29/08 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -2.3 (--) Adam Danischewski <adam.danischewski@HIDDEN> wrote: > I've been writing parsers and it would be really nice if grep could do the > following: > > *grep --quit-nm 1 -Pno "^[ \t\f]*#.*$" <(sed -n '2,$p' gen_ent.bsh)* > > If you: > *grep -m 1 -Pno "^[ \t\f]*#.*$" <(sed -n '2,$p' gen_ent.bsh)* > > Only the first match of the header block gets printed, yet it would be nice > if grep in O(n), could simply be on the look out for the first failure to > match the -o context and quit at --quit-nm non-match occurrences. I may be misunderstanding what you want, but something like awk '/pattern to match/ { print ; continue } { exit 0}' file might do what I think you want - exit on first non match. If gawk can do the same matching you're doing with grep -Pno, that is a different question. HTH, Arnold
X-Loop: help-debbugs@HIDDEN Subject: bug#28304: Feature Request - Quit on Non Match Resent-From: Adam Danischewski <adam.danischewski@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-grep@HIDDEN Resent-Date: Thu, 31 Aug 2017 17:51:02 +0000 Resent-Message-ID: <handler.28304.B28304.150420185724418 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 28304 X-GNU-PR-Package: grep X-GNU-PR-Keywords: To: arnold@HIDDEN Cc: 28304 <at> debbugs.gnu.org Received: via spool by 28304-submit <at> debbugs.gnu.org id=B28304.150420185724418 (code B ref 28304); Thu, 31 Aug 2017 17:51:02 +0000 Received: (at 28304) by debbugs.gnu.org; 31 Aug 2017 17:50:57 +0000 Received: from localhost ([127.0.0.1]:37936 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1dnTcH-0006Lm-7C for submit <at> debbugs.gnu.org; Thu, 31 Aug 2017 13:50:57 -0400 Received: from mail-qt0-f177.google.com ([209.85.216.177]:37808) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <adam.danischewski@HIDDEN>) id 1dnTcF-0006La-Tb for 28304 <at> debbugs.gnu.org; Thu, 31 Aug 2017 13:50:56 -0400 Received: by mail-qt0-f177.google.com with SMTP id h15so1493647qta.4 for <28304 <at> debbugs.gnu.org>; Thu, 31 Aug 2017 10:50:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=pSi+cwaVDOy5JsXJ27Ui792uxxzjIIyMPgEGrwsFNd0=; b=gg9XV3W9PkrBrDVTA9KJDOV8sKytCrje15ruFkCvADCQ1GvN7MH4BLxMQaJ3DCD9F4 eQe/6Ax46b8l7UXAkliFGzWFObXHTOrXKoMAnykAPweOsTGNa/bAEr8HF56W14TfLjxc LplSC3cFX207LbdZIQ0w19MynxyhY4CqICnezxb1YThttx6z4Sr9O6qlUk75ig6FoMk7 wXj0hGLemkQEOYPd5rzh57VpmsvEkEV4NI01oiawFMNmkXANw6fBuH0OfbZ+lyjfGyc9 gJ4O+VgK73/qT8XpJk47hZvXbdBY3xpzy2HqcBZaLRrmxtbew1vXDX8h9L/UCn8RtEkb mrDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=pSi+cwaVDOy5JsXJ27Ui792uxxzjIIyMPgEGrwsFNd0=; b=Cgjzm9UkazjYZyygMGoT2ls5oOw998M2qGbg1jk42eNEsz5ga3OyDOjDgEhC7jEJCa aO8nH0Xk7tCwidMotluMiCPQNXnQil3LSQGkJlGhlotMa+Qft5Sqv/cI3RImGuHwqXFW aJ0Qzag8LsPL7uNqRrCxAGoybO8kdeI/tzlZRKl0MdUs7rTqQEv5m5t2AEbDbCXW1azU 5H8CxPXojFkRwbsBZH52nWNR4TJUDDX2TK8uWsSI9fPT5B41UZhsI1jIkH9Fy3VDJPXZ ybnnhH9XCEWS85Zq3oH7o3YNUpWmqQ0zrcphGSeK3EjVqGL0u4G3DOgrmLzpf0sLUb/Q Z1kg== X-Gm-Message-State: AHYfb5jlP/Yi/OUdYayPRRZ0brcY1OZohDZDBZ6tpjmd33RQBrD093L9 Cb7zqgXIXw/H3bn0YG34/VCUpgeKdQ== X-Google-Smtp-Source: ADKCNb670qmHcfc6b5K5KKBaLgygO+TEzP6UzZgB/dmM5OPB0uLO4MAXSTOasxIbR5g5Wk5D8TyAQG1N/St9E9C10uA= X-Received: by 10.200.15.21 with SMTP id e21mr8505802qtk.35.1504201850344; Thu, 31 Aug 2017 10:50:50 -0700 (PDT) MIME-Version: 1.0 Received: by 10.12.154.5 with HTTP; Thu, 31 Aug 2017 10:50:49 -0700 (PDT) In-Reply-To: <201708311453.v7VErUtT024120@HIDDEN> References: <CAOQZJ0Hb7fsHjDrfGViRyQ742ux4qYPVf5Op74f5LWRVvWB4dA@HIDDEN> <201708311453.v7VErUtT024120@HIDDEN> From: Adam Danischewski <adam.danischewski@HIDDEN> Date: Thu, 31 Aug 2017 13:50:49 -0400 Message-ID: <CAOQZJ0GMpE9o8aszYH6R31AYAcAd9Hn3UB2mVidDQ=uNcbHs5Q@HIDDEN> Content-Type: multipart/alternative; boundary="001a11482d10f5d9be05581048cd" X-Spam-Score: 0.5 (/) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: 0.5 (/) --001a11482d10f5d9be05581048cd Content-Type: text/plain; charset="UTF-8" Yes, awk can handle it except for maybe very large files. I was trying to keep it restricted to grep, grep is already counting matches with -m but maybe GNU views this direction as becoming too programmatic from what the original vision of grep is? awk '{if($0~/^[ \t\f#]+/)print $0;else exit}' gen_ent.bsh Thanks anyway, +AMD On Thu, Aug 31, 2017 at 10:53 AM, <arnold@HIDDEN> wrote: > Adam Danischewski <adam.danischewski@HIDDEN> wrote: > > > I've been writing parsers and it would be really nice if grep could do > the > > following: > > > > *grep --quit-nm 1 -Pno "^[ \t\f]*#.*$" <(sed -n '2,$p' gen_ent.bsh)* > > > > If you: > > *grep -m 1 -Pno "^[ \t\f]*#.*$" <(sed -n '2,$p' gen_ent.bsh)* > > > > Only the first match of the header block gets printed, yet it would be > nice > > if grep in O(n), could simply be on the look out for the first failure to > > match the -o context and quit at --quit-nm non-match occurrences. > > I may be misunderstanding what you want, but something like > > awk '/pattern to match/ { print ; continue } > { exit 0}' file > > might do what I think you want - exit on first non match. > > If gawk can do the same matching you're doing with grep -Pno, that > is a different question. > > HTH, > > Arnold > --001a11482d10f5d9be05581048cd Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr"><div><div>Yes, awk can handle it except for maybe very lar= ge files. I was trying to keep it restricted to grep, grep is already count= ing matches with -m but maybe GNU views this direction as becoming too prog= rammatic from what the original vision of grep is? <br><br>awk '{if($0~= /^[ \t\f#]+/)print $0;else exit}' gen_ent.bsh<br><br></div>Thanks anywa= y, <br></div>=C2=A0+AMD <br></div><div class=3D"gmail_extra"><br><div class= =3D"gmail_quote">On Thu, Aug 31, 2017 at 10:53 AM, <span dir=3D"ltr"><<= a href=3D"mailto:arnold@HIDDEN" target=3D"_blank">arnold@HIDDEN</a>= ></span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0= 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Adam Danischewski <= <a href=3D"mailto:adam.danischewski@HIDDEN">adam.danischewski@HIDDEN<= /a>> wrote:<br> <br> > I've been writing parsers and it would be really nice if grep coul= d do the<br> > following:<br> ><br> > *grep --quit-nm 1 -Pno "^[ \t\f]*#.*$" <(sed -n '2,$p= ' gen_ent.bsh)*<br> ><br> > If you:<br> > *grep -m 1 -Pno "^[ \t\f]*#.*$" <(sed -n '2,$p' g= en_ent.bsh)*<br> ><br> > Only the first match of the header block gets printed, yet it would be= nice<br> > if grep in O(n), could simply be on the look out for the first failure= to<br> > match the -o context and quit at --quit-nm non-match occurrences.<br> <br> I may be misunderstanding what you want, but something like<br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 awk '/pattern to match/ { print ; continue = }<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 { exit 0}' file= <br> <br> might do what I think you want - exit on first non match.<br> <br> If gawk can do the same matching you're doing with grep -Pno, that<br> is a different question.<br> <br> HTH,<br> <br> Arnold<br> </blockquote></div><br></div> --001a11482d10f5d9be05581048cd--
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.