From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 89898 invoked by alias); 4 Jan 2018 19:51:32 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 89889 invoked by uid 89); 4 Jan 2018 19:51:31 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.6 required=5.0 tests=AWL,BAYES_05,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=Karr, karr, arrl, substitute X-HELO: mail-io0-f172.google.com Received: from mail-io0-f172.google.com (HELO mail-io0-f172.google.com) (209.85.223.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 04 Jan 2018 19:51:30 +0000 Received: by mail-io0-f172.google.com with SMTP id 87so3410915ior.5 for ; Thu, 04 Jan 2018 11:51:30 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:reply-to:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=2li5U3sXgm3ngRsu0Go4fcZhUt7p0Q5MyIfMV3FD1U0=; b=uWBLqgYhh/3jI/V7v+AjfCrnorUF/wpBOeOecvkveKTXL6XlXJL5SwuDj+9k10CcT4 7uvCG8zsyeHkHumNzMw7+oE184lXrZN7t3SlI+A2ApeLNa4ZshoVQwdMvH0JqN8xlnuH 5u4dQjlIzvynpNIrQ3YWVgUWmX5OMJTBUTFFfroX9kJkrpX9EseivCo18WMpeDejlZQN HnMypZsoGwvngkFQ5kOgkXnoiHvmyWdCNSJ2iOtq+FoG/PHW8yBTlK+aHOUZkjOhLio1 8Sycadm53Q0n6KkfZ0ileoKxYp0AOGtWJqTsfcHtVv9gttYDGwZQ9s9VEqO23QQPSzN/ qd8Q== X-Gm-Message-State: AKGB3mIChy+LcVGIqcui+riUpREHE6Ky4PfOK3mor25nUL9+vzvDwjdo VwdyT5jGF/bX5yKxQ1Me3H2gwQ== X-Google-Smtp-Source: ACJfBosTVMb0xL0KA0XATA0SSlSq5ICMnczFXS3g0p0VEVFlEAI0I/FS1Qft03AgrcVD7z17lRN2EQ== X-Received: by 10.107.191.133 with SMTP id p127mr823724iof.246.1515095488792; Thu, 04 Jan 2018 11:51:28 -0800 (PST) Received: from [192.168.0.19] (d4-50-42-50.try.wideopenwest.com. [50.4.50.42]) by smtp.gmail.com with ESMTPSA id a9sm2511241ioa.8.2018.01.04.11.51.28 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Jan 2018 11:51:28 -0800 (PST) Subject: Re: Grep can't match characters before EOL marker without ^M To: cygwin@cygwin.com References: <00e694f3-1e50-24be-95dd-8b6bf2bb1323@aol.com> Reply-To: cygwin@cygwin.com From: cyg Simple Message-ID: Date: Thu, 04 Jan 2018 19:51:00 -0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: <00e694f3-1e50-24be-95dd-8b6bf2bb1323@aol.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-IsSubscribed: yes X-SW-Source: 2018-01/txt/msg00020.txt.bz2 On 1/3/2018 1:39 PM, arrl via cygwin wrote: > On 1/3/2018 12:31 PM, David Karr wrote: >> My cygwin version appears to be "2.9.0(0.318/5/3)". >> >> If I have a text file that has a line that ends with "abc", and I try >> to grep for "abc$", it doesn't match. I find that it does match "$" >> and "abc^M$". >> >> I've read some of the documentation about line endings in Cygwin. >> >> I need to write some scripting that works on both Cygwin and Linux. >> What do I need to do here? >> > > Consider running dos2unix on files containing ^M at line ends. > You might wish to test for a binary file before running dos2unix on it though or even using sed to substitute ^M$ to remove them. Binary data could contain a CRLF that would destroy the binary file if CR is removed. Also consider doing the same instruction regardless of the OS because you never know when your script meets a file from a different OS. In the business world many people send files from Windows to *NIX and vice versa. If a text file from *NIX is sent to a user of Windows be sure that the file contains the appropriate CRLF or the user will just see garbage unless they are a DevOPS person who knows how to deal with the file. I can't count the number of times I've had to resend a file or help someone adjust one just because the Windows default for .txt files is Notepad which uses the CR to advance to the next line of the GUI. -- cyg Simple -- 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