GNU bug report logs -
#20474
tr command
Previous Next
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.
Full log
Message #15 received at 20474 <at> debbugs.gnu.org (full text, mbox):
[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)]
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.