bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#20474: tr command


From: Eric Blake
Subject: bug#20474: tr command
Date: Thu, 30 Apr 2015 11:10:52 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0

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

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]