From debbugs-submit-bounces@debbugs.gnu.org Sat Feb 03 12:29:37 2018 Received: (at submit) by debbugs.gnu.org; 3 Feb 2018 17:29:37 +0000 Received: from localhost ([127.0.0.1]:55856 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ei1dA-0007FF-5j for submit@debbugs.gnu.org; Sat, 03 Feb 2018 12:29:37 -0500 Received: from eggs.gnu.org ([208.118.235.92]:36093) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ei0PW-0005UA-78 for submit@debbugs.gnu.org; Sat, 03 Feb 2018 11:11:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ei0PQ-00037X-Ay for submit@debbugs.gnu.org; Sat, 03 Feb 2018 11:11:21 -0500 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_20,FREEMAIL_FROM autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:35564) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ei0PQ-00037I-8L for submit@debbugs.gnu.org; Sat, 03 Feb 2018 11:11:20 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55275) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ei0PP-0002np-3D for bug-sed@gnu.org; Sat, 03 Feb 2018 11:11:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ei0PK-00033B-58 for bug-sed@gnu.org; Sat, 03 Feb 2018 11:11:19 -0500 Received: from smtp-s06-b.vera.com.uy ([200.40.31.25]:51204 helo=mail.vera.com.uy) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ei0PJ-0002xn-RW for bug-sed@gnu.org; Sat, 03 Feb 2018 11:11:14 -0500 Received: from avas07.in.vera.com.uy (avas07.in.vera.com.uy [172.24.32.35]) by mta06.in.vera.com.uy (Postfix) with ESMTPS id 7F40430286A for ; Sat, 3 Feb 2018 13:11:08 -0300 (UYT) Received: from mail.vera.com.uy (unknown [172.24.31.10]) by avas07.in.vera.com.uy (Postfix) with ESMTPS for ; Sat, 3 Feb 2018 13:11:05 -0300 (-03) Received: from [10.0.0.9] (16.208.108.200.static.dedicado.com.uy [200.108.208.16]) by mta01.in.vera.com.uy (Postfix) with ESMTPA id 63AA5221C17 for ; Sat, 3 Feb 2018 13:11:05 -0300 (UYT) To: bug-sed@gnu.org From: Roger Adair Subject: sed Message-ID: <087c188a-30bf-787a-2196-e08e9d32f9e9@adinet.com.uy> Date: Sat, 3 Feb 2018 13:11:04 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] 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-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Sat, 03 Feb 2018 12:29:35 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) Hi, I'm using Linux Mint 18.3 with sed version sed (GNU sed) 4.2.2 when I execute the following command: $ sed 's/c$/7/g' test.data.asc where the contents of test.data.asc is: abc=C2=A0 abc 123456 I get the following output: abc=C2=A0 abc 123456 Whereas I would expect the following: abc=C2=A0 ab7 123456 If I leave the $ out of the command "ab7 ab7" appears. What am I doing wrong?=C2=A0 Many thanks for reading my email. Roger From debbugs-submit-bounces@debbugs.gnu.org Sat Feb 03 14:24:46 2018 Received: (at 30336) by debbugs.gnu.org; 3 Feb 2018 19:24:46 +0000 Received: from localhost ([127.0.0.1]:55919 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ei3Qc-0001Sd-1T for submit@debbugs.gnu.org; Sat, 03 Feb 2018 14:24:46 -0500 Received: from mail-pg0-f46.google.com ([74.125.83.46]:40767) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ei3QZ-0001SQ-SK for 30336@debbugs.gnu.org; Sat, 03 Feb 2018 14:24:44 -0500 Received: by mail-pg0-f46.google.com with SMTP id g16so15674141pgn.7 for <30336@debbugs.gnu.org>; Sat, 03 Feb 2018 11:24:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=865HHVuxLfwbksWf4cDrAU9uQeiPbcQv2Gp7YhdQjLQ=; b=VXQ0dMfuDjMUUhugnG3xVAqeKU3hAJ4lqaIMt4nbyyqolrNOZnAmGpylGfv7g58yY0 vNVGJd/H1I0Ji76P9XGKLbd9aeftJsUbbiGOeGdfy4zv02b9TOk3Jj5ZsYi0ZQPg6rhL QO7D6hkkPiTiRo02rB6DwW2uHEublT184ng+FR/+5yNkbnX1xuOz9gGPuVXb9bdfcnlC CX5JgpaBvjRAejJJ5PDxF+frVuIIQSmLX2rPPCWfxGigNIrFUMZmThnim/M7tiKLj1EI MLw9rhvQwvbTFBZZk7xXvx3O1scYE33LExamzMUPsUlfe7oSNhfbWWiMmrIUVJMWetV+ WX1w== 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:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=865HHVuxLfwbksWf4cDrAU9uQeiPbcQv2Gp7YhdQjLQ=; b=mZA+lT1Mt3FRmoJF9CXibV9fT2Kwu0PaC6BuHwQLBH7vOdLcSesFPwBd6QHhAJOsNp 7sziuSX/y5xu8fSlkf5Vpk/wHUsVnjCUixEJAmzVAPMHYx+nDqtFYCfG6nhpi4nbYpav UL80oODSLmRJ/uZ4Dun6d3f20WExLU2W7dXBYxFB0ertelTeD49pLQPXmOFISUeoCRmm JNEk1FIu9UdjnulG0IZRqx4PtEDkaqZj5/ugM+0gQyQHtBUDUowoXhLhg16qLFPeQBz1 7bPY+kusxD/nS7yrOZEbPvE+gYCWDsbq8G+lV6pP5s5Q1XTI5FNL6z0xVaLKlMITum3L azMQ== X-Gm-Message-State: AKwxytdqKe+rWBi5NEqo21BxJNt8dys5G/vLSpLMc14FLX8EnPPuhjNs UId/MbZUrDr7U1kttsUzP5KNYWym X-Google-Smtp-Source: AH8x2245GXEWfFUy4vGM7fPp2ef6usZVo+PFJDc4gdln9LlHrwBty7SCua4k/YPvHI4Py5wCpDBu+w== X-Received: by 10.101.68.199 with SMTP id g7mr2970033pgs.21.1517685877836; Sat, 03 Feb 2018 11:24:37 -0800 (PST) Received: from [192.168.88.239] (moose.housegordon.com. [184.68.105.38]) by smtp.googlemail.com with ESMTPSA id w10sm7151976pgc.69.2018.02.03.11.24.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 03 Feb 2018 11:24:37 -0800 (PST) Subject: Re: bug#30336: sed To: Roger Adair , 30336@debbugs.gnu.org References: <087c188a-30bf-787a-2196-e08e9d32f9e9@adinet.com.uy> From: Assaf Gordon Message-ID: <8dce7eb2-44f3-aeab-f187-8004acad294e@gmail.com> Date: Sat, 3 Feb 2018 12:24:35 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <087c188a-30bf-787a-2196-e08e9d32f9e9@adinet.com.uy> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 30336 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) Hello, On 2018-02-03 09:11 AM, Roger Adair wrote: > when I execute the following command: > > $ sed 's/c$/7/g' test.data.asc > > where the contents of test.data.asc is: > > abc  abc > 123456 > > I get the following output: > > abc  abc > 123456 > > Whereas I would expect the following: > > abc  ab7 > 123456 > > If I leave the $ out of the command "ab7 ab7" appears. > > What am I doing wrong?  Many thanks for reading my email. My immediate guess would be that the file has dos/mac line endings (e.g. CRLF "\r\n" instead of just line-feed "\n"). You can test it by using 'file', like so: $ file test.data.sac test.data.asc: ASCII text, with CRLF line terminators Or by printing it's content like so: $ od -tcz test.data.asc 0000000 a b c a b c \r \n >abc abc..< If you see only "\r" in the output - the file has MAC line-endings. If you see both "\r\n" - the file has dos/windows line endings. In unix, GNU sed "$" only matches "\n", and "\r" is just another character. Some ways to work-around it: 1. Use "dos2unix" or "mac2unix" on the file (simplest and recommend). 2. Use the following to strip "\r" from the file (assuming it also has "\n"): cat test.data.asc \ | tr -d '\r' \ | sed 's/c$/7/g' If the file has only "\r", convert them to "\n": cat test.data.asc \ | tr '\r' '\n' \ | sed 's/c$/7/g' 3. Add sed command to remove "\r" before doing the other substitution: sed -e 's/\r$//g' -e 's/c$/7/g' test.data.asc 4. Or modify the regex itself to optionally match "\r": sed 's/c\r*$/7/g' test.data.asc --- If none of the above work, and you suspect another problem, please provide a small fragment of your input file so we can reproduce the issue. regards, - assaf From debbugs-submit-bounces@debbugs.gnu.org Sun Feb 04 20:17:25 2018 Received: (at 30336-done) by debbugs.gnu.org; 5 Feb 2018 01:17:25 +0000 Received: from localhost ([127.0.0.1]:57507 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eiVPP-00011a-8K for submit@debbugs.gnu.org; Sun, 04 Feb 2018 20:17:25 -0500 Received: from mail-io0-f178.google.com ([209.85.223.178]:34595) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eiVPN-00011O-7N for 30336-done@debbugs.gnu.org; Sun, 04 Feb 2018 20:17:21 -0500 Received: by mail-io0-f178.google.com with SMTP id c17so28568556iod.1 for <30336-done@debbugs.gnu.org>; Sun, 04 Feb 2018 17:17:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:references:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=3ftmgJDDyFBWwiYjBdbmrSJOC/t8K/W0vT15AhKFKO4=; b=CcSK7fqQc5UxPeYf4rKv9LgMrV/ivAJmJ6Lk3nVbF+j67r83Gz8KbQtD00ILkjRljH 9o/gu6zN4n+hyelKXQmKvSSe4inzWwolcZTDocfBL5QKjXiETCav3N+2o4ETpfOoyQuV XuNRVW16znXkvMkOo0z1aKqTCFXgevOhI/joT4uH51QDb7DaD3wEaFcmLcJxP3qy4UAn BKEYrULgVP2b2OoEQWsOZoshHiJGqFLJaoZCmrZyz0dg/xTc2QtswfbX4h5mxG/KDGsl 4Fy2bTEyyr5N/oLH4x1cSOYn/3viYJ7kTdE9M+d0i9y3mj4wOjLq3rWLCzqStLeW4Fp5 oJ2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=3ftmgJDDyFBWwiYjBdbmrSJOC/t8K/W0vT15AhKFKO4=; b=L1Nmkrj0zkA67B5/is2SuLB/il4xDlwhgVYniiEQnTaDtEqNlvegOr67qHCuYXBxMz pxbYLrreGlYct/QGqZOpRjoIZxrWRRodtOhz1+UBIvs1TWntIjV7BuEAhmntCB64Jb6T yhj1VEQs0IxyiVJFFIciRm/fFVHOK49MPXNWDO/VGlirxsLWx3xFYeqmEO2b+GHmk+KP oZfcRuvw3hF8i4V0RjbWCpQf0NutMQgkTaAnD+zqcPVSQxzAg06ew6NOUfGt8i7lwTQa XwSZwLjQ4oEbSWgs8h1aWRTBkX/mJQ+Ng9KAK3+w04dprpYTbfDXdhhHDXk/+NpWnQ5D QLvw== X-Gm-Message-State: AKwxytcjHTZ5J6+dmy1GUMtoZ7vLy9l0tTauGN4H8Nd/ULjxsILMo2Z7 Wd1wYfDNu0Sw+Pfu7jdKHeNJO4/j X-Google-Smtp-Source: AH8x225m8pLEzMQzEPaw7lbObn8nowp1Iann/xsTTDAcjfuWKikFoBgp4UenKE35zAg/JwZUZTifrQ== X-Received: by 10.107.7.41 with SMTP id 41mr52235084ioh.249.1517793435250; Sun, 04 Feb 2018 17:17:15 -0800 (PST) Received: from [192.168.88.239] (moose.housegordon.com. [184.68.105.38]) by smtp.googlemail.com with ESMTPSA id c15sm1568243itd.4.2018.02.04.17.17.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 04 Feb 2018 17:17:14 -0800 (PST) Subject: Re: bug#30336: sed From: Assaf Gordon To: Roger Adair , 30336-done@debbugs.gnu.org References: <087c188a-30bf-787a-2196-e08e9d32f9e9@adinet.com.uy> <8dce7eb2-44f3-aeab-f187-8004acad294e@gmail.com> Message-ID: <6f3a8d84-be53-2609-6c33-aeff960803ef@gmail.com> Date: Sun, 4 Feb 2018 18:17:13 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <8dce7eb2-44f3-aeab-f187-8004acad294e@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 30336-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On 2018-02-03 12:24 PM, Assaf Gordon wrote: > On 2018-02-03 09:11 AM, Roger Adair wrote: >> when I execute the following command: >> >> $ sed 's/c$/7/g' test.data.asc >> [...] > My immediate guess would be that the file has dos/mac line endings > (e.g. CRLF "\r\n" instead of just line-feed "\n"). Confirmed off-list this is the issue - I'm thus closing this bug. regards, - assaf From unknown Fri Jun 20 07:27:38 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Mon, 05 Mar 2018 12:24:05 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator