delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2012/11/26/14:20:28

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,KHOP_THREADED,RCVD_IN_DNSWL_NONE,RCVD_IN_HOSTKARMA_YE
X-Spam-Check-By: sourceware.org
X-Yahoo-SMTP: mjD.OBqswBAPbVUxYJaYPvc61jLEnpq8VnBwJGdbEJOPA9xw
Message-ID: <50B3C109.70309@sbcglobal.net>
Date: Mon, 26 Nov 2012 19:20:41 +0000
From: Greg Chicares <gchicares AT sbcglobal DOT net>
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:16.0) Gecko/20121026 Thunderbird/16.0.2
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: grep and the -f switch
References: <ogf7b89pd41ok64j5lcc2emvh3d7rg097k AT 4ax DOT com>
In-Reply-To: <ogf7b89pd41ok64j5lcc2emvh3d7rg097k@4ax.com>
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

On 2012-11-26 19:08Z, Roy Jensen wrote:
> I've created a text file (in Windows) with the text patterns I wish to
> search for. Using the -f switch, grep only searches for the last
> pattern in the file. If there is a blank line at the end, grep finds
> nothing.
> 
> grep -a -A 4 -f pattern.txt my.file > output.txt

In case the file of patterns contains a carriage return, try:
  d2u pattern.txt
then repeat the 'grep' command.


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019