GNU bug report logs - #20474
tr command

Previous Next

Package: coreutils;

Reported by: Joseph Piette <Joe.Piette <at> cantire.com>

Date: Thu, 30 Apr 2015 16:47:01 UTC

Severity: normal

Tags: notabug

Done: Pádraig Brady <P <at> draigBrady.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 20474 in the body.
You can then email your comments to 20474 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-coreutils <at> gnu.org:
bug#20474; Package coreutils. (Thu, 30 Apr 2015 16:47:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Joseph Piette <Joe.Piette <at> cantire.com>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Thu, 30 Apr 2015 16:47:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Joseph Piette <Joe.Piette <at> cantire.com>
To: "bug-coreutils <at> gnu.org" <bug-coreutils <at> gnu.org>
Subject: tr command
Date: Thu, 30 Apr 2015 16:31:01 +0000
[Message part 1 (text/plain, inline)]
Hello:

When transferring files from the Windows environment to the Linux environment we execute a script to remove the \cr characters. The script performs a simple

tr -d '\r'  < input  > output

Recently we were testing with files that contained a string with a single quote - "Paym't"

What the tr command is doing is not only removing the "\cr" characters but also the single quote. What we ended up with was "Paymt"


Any ideas?

Ami I using the tr command incorrectly?


We are running:

cat /proc/version
Linux version 2.6.32-504.12.2.el6.x86_64 (mockbuild <at> x86-027.build.eng.bos.redhat.com) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-9) (GCC) ) #1 SMP Sun Feb 1 12:14:02 EST 2015

cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.6 (Santiago)


Thanks.

________________________________

[email-signature-image_0003_CT_IconLogo_Sml_RGB.png]

Joe Piette
Senior Technical Specialist
Integration Architecture
Canadian Tire Corporation
2190 Yonge St.
Toronto, ON
M4P 2V8
T: 416.480.8867  |  C: 416.433.4124
Joe.Piette <at> cantire.com


[email-signature-image_0002_COC_Standalone_Mark_4C_BIL_ENG.png]



[Message part 2 (text/html, inline)]
[image001.png (image/png, inline)]
[image003.png (image/png, inline)]
[image002.png (image/png, inline)]
[image004.png (image/png, inline)]

Information forwarded to bug-coreutils <at> gnu.org:
bug#20474; Package coreutils. (Thu, 30 Apr 2015 17:08:02 GMT) Full text and rfc822 format available.

Message #8 received at 20474 <at> debbugs.gnu.org (full text, mbox):

From: Pádraig Brady <P <at> draigBrady.com>
To: Joseph Piette <Joe.Piette <at> cantire.com>, 20474 <at> debbugs.gnu.org
Subject: Re: bug#20474: tr command
Date: Thu, 30 Apr 2015 18:06:56 +0100
tag 20474 notabug
close 20474
stop

On 30/04/15 17:31, Joseph Piette wrote:
> Hello:
> 
> When transferring files from the Windows environment to the Linux environment we execute a script to remove the \cr characters. The script performs a simple
> 
> tr -d '\r'  < input  > output
> 
> Recently we were testing with files that contained a string with a single quote – “Paym’t”
> What the tr command is doing is not only removing the “\cr” characters but also the single quote. What we ended up with was “Paymt”

I'm guessing that you're using a unibyte locale
and that your tr command is using curly quotes rather that single quotes.
That in turn is passed by the shell to tr which will then delete such curly quotes?

Pádraig.




Added tag(s) notabug. Request was from Pádraig Brady <P <at> draigBrady.com> to control <at> debbugs.gnu.org. (Thu, 30 Apr 2015 17:08:03 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 20474 <at> debbugs.gnu.org and Joseph Piette <Joe.Piette <at> cantire.com> Request was from Pádraig Brady <P <at> draigBrady.com> to control <at> debbugs.gnu.org. (Thu, 30 Apr 2015 17:08:03 GMT) Full text and rfc822 format available.

Information forwarded to bug-coreutils <at> gnu.org:
bug#20474; Package coreutils. (Thu, 30 Apr 2015 17:11:03 GMT) Full text and rfc822 format available.

Message #15 received at 20474 <at> debbugs.gnu.org (full text, mbox):

From: Eric Blake <eblake <at> redhat.com>
To: Joseph Piette <Joe.Piette <at> cantire.com>, 20474 <at> debbugs.gnu.org
Subject: Re: bug#20474: tr command
Date: Thu, 30 Apr 2015 11:10:52 -0600
[Message part 1 (text/plain, inline)]
On 04/30/2015 10:31 AM, Joseph Piette wrote:
> Hello:
> 
> When transferring files from the Windows environment to the Linux environment we execute a script to remove the \cr characters. The script performs a simple
> 
> tr -d '\r'  < input  > output
> 
> Recently we were testing with files that contained a string with a single quote - "Paym't"
> 
> What the tr command is doing is not only removing the "\cr" characters but also the single quote. What we ended up with was "Paymt"

It looks like correct usage if you are using a POSIX shell.  But you
didn't specify if that was the case. Are you running the script on
Windows, using 'cmd' to drive a pre-built version of tr for Windows?  If
so, it is very likely that the unusual quoting rules for cmd (very
different from POSIX shell) are the cause for your problem.  That is,
the command line being constructed may be something like 'tr -d "'\\r'"
...', where you are unintentionally passing literal ' on to tr, and tr
is then faithfully deleting single quotes.  If you are indeed running tr
on Windows, try:

echo tr -d '\r'

to see if the cmd shell is getting in the way.  Or move your files to
Linux, and run tr on Linux rather than on Windows, to ensure that you
are not being bitten by Windows oddities.

Another thing to try: the 'dos2unix' command exists in many Linux
distros as a way to automate the work without having to figure out the
commands to run yourself.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

[signature.asc (application/pgp-signature, attachment)]

Information forwarded to bug-coreutils <at> gnu.org:
bug#20474; Package coreutils. (Fri, 01 May 2015 12:33:02 GMT) Full text and rfc822 format available.

Message #18 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Erik Auerswald <auerswal <at> unix-ag.uni-kl.de>
To: bug-coreutils <at> gnu.org
Subject: Re: bug#20474: tr command
Date: Fri, 1 May 2015 14:32:38 +0200
Hi,

On Thu, Apr 30, 2015 at 11:10:52AM -0600, Eric Blake wrote:
> On 04/30/2015 10:31 AM, Joseph Piette wrote:
> > When transferring files from the Windows environment to the Linux environment we execute a script to remove the \cr characters. The script performs a simple
> > 
> > tr -d '\r'  < input  > output
> > [...]
> 
> Another thing to try: the 'dos2unix' command exists in many Linux
> distros as a way to automate the work without having to figure out the
> commands to run yourself.

Many other Linux distros provide the 'recode' command instead.

Erik




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 30 May 2015 11:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 10 years and 101 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.