delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2018/01/04/14:51:44

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:subject:to:references:reply-to:from:message-id
:date:mime-version:in-reply-to:content-type
:content-transfer-encoding; q=dns; s=default; b=EaAU5Cjdrznv+dQ7
/CUSGurWATpKmntc0xCvR1I0yI/Zpf4sLWeTbKW9+pBRJUEaKAzjxUB5CWIG2IQE
BQc4xoasEv/rRTMdNxF8SjlP36AglZlPwHNLjUIAZ7qWiyYu1UI9wjNbox9GVLTW
IA/CxXzXekmkYb92C/mgSYleqWs=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:subject:to:references:reply-to:from:message-id
:date:mime-version:in-reply-to:content-type
:content-transfer-encoding; s=default; bh=YboX+bVI0nQ4p19uHhTuiW
HJaZw=; b=DASfGkuPUAYQuW2QR+zc/T851ldFNNIPPygseMPSXT7Zfg4gLQ6XR8
r7Tt7VXg3fH+PeGa3rBVSuFh7eHIFxrezdsC6jPPO+nyzuaizzZhA4pyyW5muIE9
R4Tv901VU5VKTuC/2Q/vmaXQQYqkF84S/EjBgfLCVDkDREUnv2txo=
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
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
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)
Subject: Re: Grep can't match characters before EOL marker without ^M
To: cygwin AT cygwin DOT com
References: <CAA5t8Vrr_GcYqaLq-1noAj7mxQ7KsMnd43k10-ef1anuCr60Tg AT mail DOT gmail DOT com> <00e694f3-1e50-24be-95dd-8b6bf2bb1323 AT aol DOT com>
Reply-To: cygwin AT cygwin DOT com
From: cyg Simple <cygsimple AT gmail DOT com>
Message-ID: <d35c9962-66e6-e6ce-12a1-646281f537bf@gmail.com>
Date: Thu, 4 Jan 2018 14:51:19 -0500
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>
X-IsSubscribed: yes

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

- Raw text -


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