bug#20474: tr command
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#20474: tr command
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.
bug#20474: tr command
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 (mockbu...@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.pie...@cantire.com [email-signature-image_0002_COC_Standalone_Mark_4C_BIL_ENG.png]
bug#20474: tr command
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 Description: OpenPGP digital signature