<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: tr scripts giving wrong results in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/tr-scripts-giving-wrong-results/m-p/2810473#M84155</link>
    <description>Hi Shane:&lt;BR /&gt;&lt;BR /&gt;Try;&lt;BR /&gt;&lt;BR /&gt;# UPPERNAME=`print $NAME | tr '[a-z]' '[A-Z]'` &lt;BR /&gt;&lt;BR /&gt;...or...&lt;BR /&gt;&lt;BR /&gt;UPPERNAME=`print $NAME | tr '[:lower:]' '[:upper:]'`&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
    <pubDate>Fri, 20 Sep 2002 13:22:10 GMT</pubDate>
    <dc:creator>James R. Ferguson</dc:creator>
    <dc:date>2002-09-20T13:22:10Z</dc:date>
    <item>
      <title>tr scripts giving wrong results</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/tr-scripts-giving-wrong-results/m-p/2810468#M84150</link>
      <description>I have a simple test script that uses the tr command. When we run the script, most times we get the correct result but we have determined that if we run the script with a touched file name of a single character in the directory we do not get the proper results. Can someone tell me why having a single character filename changes the results. If somone wants to see the results try the following in a script.  NAME=bcwbird&lt;BR /&gt;UPPERNAME=`print $NAME | tr [a-z] [A-Z]`&lt;BR /&gt;print $NAME&lt;BR /&gt;print $UPPERNAME&lt;BR /&gt;exit&lt;BR /&gt;&lt;BR /&gt;Then touch a file called p in the directory you are executing from ie be in your home directory and touch p then execute the above script.&lt;BR /&gt;No translation occurs. change the p to an a and you get different results. My shell is ksh, seems to perform the same in sh.</description>
      <pubDate>Fri, 20 Sep 2002 13:10:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/tr-scripts-giving-wrong-results/m-p/2810468#M84150</guid>
      <dc:creator>Medavie</dc:creator>
      <dc:date>2002-09-20T13:10:55Z</dc:date>
    </item>
    <item>
      <title>Re: tr scripts giving wrong results</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/tr-scripts-giving-wrong-results/m-p/2810469#M84151</link>
      <description>Shane,&lt;BR /&gt;&lt;BR /&gt;I though you were full of it, but you are right, this is what I got:&lt;BR /&gt;&lt;BR /&gt;# ./io&lt;BR /&gt;bcwbird&lt;BR /&gt;BCWBIRD&lt;BR /&gt;# touch p&lt;BR /&gt;# ./io&lt;BR /&gt;bcwbird&lt;BR /&gt;bcwbird&lt;BR /&gt;# touch a&lt;BR /&gt;# ./io&lt;BR /&gt;tr: The combination of options and String parameters is not legal.&lt;BR /&gt;Usage: tr [ -c | -cds | -cs | -ds | -s ] [-A] String1 String2&lt;BR /&gt;       tr [ -cd | -cs | -d | -s ] [-A] String1&lt;BR /&gt;bcwbird&lt;BR /&gt;&lt;BR /&gt;#     &lt;BR /&gt;&lt;BR /&gt;I'm gonna analize it, be back soon&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry</description>
      <pubDate>Fri, 20 Sep 2002 13:16:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/tr-scripts-giving-wrong-results/m-p/2810469#M84151</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2002-09-20T13:16:48Z</dc:date>
    </item>
    <item>
      <title>Re: tr scripts giving wrong results</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/tr-scripts-giving-wrong-results/m-p/2810470#M84152</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I tried your script and it seems to work correctly.  I'm a little confused.  Are you passing the filename as a parameter to the script?  I don't see how your script (as shown in your post) has anything to do with any file name.  &lt;BR /&gt;&lt;BR /&gt;Could it be that you have an alias in your shell for the letters 'a' or 'p' that could be throwing you off?&lt;BR /&gt;&lt;BR /&gt;JP&lt;BR /&gt;</description>
      <pubDate>Fri, 20 Sep 2002 13:16:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/tr-scripts-giving-wrong-results/m-p/2810470#M84152</guid>
      <dc:creator>John Poff</dc:creator>
      <dc:date>2002-09-20T13:16:54Z</dc:date>
    </item>
    <item>
      <title>Re: tr scripts giving wrong results</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/tr-scripts-giving-wrong-results/m-p/2810471#M84153</link>
      <description>Ok.  Now i see, from Harry's post.  That's weird!&lt;BR /&gt;&lt;BR /&gt;JP&lt;BR /&gt;</description>
      <pubDate>Fri, 20 Sep 2002 13:18:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/tr-scripts-giving-wrong-results/m-p/2810471#M84153</guid>
      <dc:creator>John Poff</dc:creator>
      <dc:date>2002-09-20T13:18:56Z</dc:date>
    </item>
    <item>
      <title>Re: tr scripts giving wrong results</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/tr-scripts-giving-wrong-results/m-p/2810472#M84154</link>
      <description>Shane,&lt;BR /&gt;&lt;BR /&gt;You need to put the TRANSLATION strings in QUOTES:&lt;BR /&gt;&lt;BR /&gt;# cat ./io&lt;BR /&gt;#!/sbin/sh&lt;BR /&gt;NAME=bcwbird&lt;BR /&gt;UPPERNAME=`print $NAME | tr "[a-z]" "[A-Z]"`&lt;BR /&gt;print $NAME&lt;BR /&gt;print $UPPERNAME&lt;BR /&gt;# ./io&lt;BR /&gt;bcwbird&lt;BR /&gt;BCWBIRD&lt;BR /&gt;# rm p a&lt;BR /&gt;# ./io&lt;BR /&gt;bcwbird&lt;BR /&gt;BCWBIRD&lt;BR /&gt;# touch p&lt;BR /&gt;# ./io&lt;BR /&gt;bcwbird&lt;BR /&gt;BCWBIRD&lt;BR /&gt;# touch a&lt;BR /&gt;# ./io&lt;BR /&gt;bcwbird&lt;BR /&gt;BCWBIRD&lt;BR /&gt;#    &lt;BR /&gt;&lt;BR /&gt;The issue is the `` executing and translating characters.&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry</description>
      <pubDate>Fri, 20 Sep 2002 13:20:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/tr-scripts-giving-wrong-results/m-p/2810472#M84154</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2002-09-20T13:20:32Z</dc:date>
    </item>
    <item>
      <title>Re: tr scripts giving wrong results</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/tr-scripts-giving-wrong-results/m-p/2810473#M84155</link>
      <description>Hi Shane:&lt;BR /&gt;&lt;BR /&gt;Try;&lt;BR /&gt;&lt;BR /&gt;# UPPERNAME=`print $NAME | tr '[a-z]' '[A-Z]'` &lt;BR /&gt;&lt;BR /&gt;...or...&lt;BR /&gt;&lt;BR /&gt;UPPERNAME=`print $NAME | tr '[:lower:]' '[:upper:]'`&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Fri, 20 Sep 2002 13:22:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/tr-scripts-giving-wrong-results/m-p/2810473#M84155</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2002-09-20T13:22:10Z</dc:date>
    </item>
    <item>
      <title>Re: tr scripts giving wrong results</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/tr-scripts-giving-wrong-results/m-p/2810474#M84156</link>
      <description>Cool.  Snagged by the quotes.  That's why I don't fool with 'tr' when I'm switching case in scripts.  I prefer to use 'typeset':&lt;BR /&gt;&lt;BR /&gt;typeset -u UPPERNAME=$NAME&lt;BR /&gt;&lt;BR /&gt;will work fine.&lt;BR /&gt;&lt;BR /&gt;JP&lt;BR /&gt;</description>
      <pubDate>Fri, 20 Sep 2002 13:23:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/tr-scripts-giving-wrong-results/m-p/2810474#M84156</guid>
      <dc:creator>John Poff</dc:creator>
      <dc:date>2002-09-20T13:23:07Z</dc:date>
    </item>
    <item>
      <title>Re: tr scripts giving wrong results</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/tr-scripts-giving-wrong-results/m-p/2810475#M84157</link>
      <description>You need to quote the arguments to the tr command. &lt;BR /&gt;&lt;BR /&gt;tr [a-z] [A-Z] should read&lt;BR /&gt;tr "[a-z]" "[A-Z]"&lt;BR /&gt;&lt;BR /&gt;Without the quotes, the shell matches [a-z] with the filename 'p' (or  'a') and so the first argument supplied to tr is the filename.&lt;BR /&gt;&lt;BR /&gt;If you are simply converting a string to uppercase then a more efficient way is to declare an uppercase variable thus:-&lt;BR /&gt;&lt;BR /&gt;typeset -u UPPERNAME&lt;BR /&gt;&lt;BR /&gt;NAME=bcwbird&lt;BR /&gt;UPPERNAME=${NAME}&lt;BR /&gt;print ${UPPERNAME}&lt;BR /&gt;&lt;BR /&gt;BCWBIRD&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;John&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 20 Sep 2002 13:23:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/tr-scripts-giving-wrong-results/m-p/2810475#M84157</guid>
      <dc:creator>John Palmer</dc:creator>
      <dc:date>2002-09-20T13:23:39Z</dc:date>
    </item>
    <item>
      <title>Re: tr scripts giving wrong results</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/tr-scripts-giving-wrong-results/m-p/2810476#M84158</link>
      <description>Shane,&lt;BR /&gt;&lt;BR /&gt;this is easier to show:&lt;BR /&gt;&lt;BR /&gt;# rm a p&lt;BR /&gt;# echo a | tr [a-z] [A-Z]&lt;BR /&gt;A&lt;BR /&gt;# touch p&lt;BR /&gt;# echo a | tr [a-z] [A-Z]&lt;BR /&gt;a&lt;BR /&gt;# touch a&lt;BR /&gt;# echo a | tr [a-z] [A-Z]&lt;BR /&gt;tr: The combination of options and String parameters is not legal.&lt;BR /&gt;Usage: tr [ -c | -cds | -cs | -ds | -s ] [-A] String1 String2&lt;BR /&gt;       tr [ -cd | -cs | -d | -s ] [-A] String1&lt;BR /&gt;# echo a | tr "[a-z]" "[A-Z]"&lt;BR /&gt;A&lt;BR /&gt;#    &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry</description>
      <pubDate>Fri, 20 Sep 2002 13:25:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/tr-scripts-giving-wrong-results/m-p/2810476#M84158</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2002-09-20T13:25:03Z</dc:date>
    </item>
    <item>
      <title>Re: tr scripts giving wrong results</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/tr-scripts-giving-wrong-results/m-p/2810477#M84159</link>
      <description>The single character filename is not used in the script, it only causes the script not to give the correct results if the single character filename is in the directory you execute from. If you move the single character filename to a multiple character file name the script will work. (ie mv p pp) and then run the script and translation will occur. As long as there is a single character filename in the directory you execute from the results are incorrect.</description>
      <pubDate>Fri, 20 Sep 2002 13:25:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/tr-scripts-giving-wrong-results/m-p/2810477#M84159</guid>
      <dc:creator>Medavie</dc:creator>
      <dc:date>2002-09-20T13:25:53Z</dc:date>
    </item>
    <item>
      <title>Re: tr scripts giving wrong results</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/tr-scripts-giving-wrong-results/m-p/2810478#M84160</link>
      <description>The trick is to put [a-z] in quotes. The shell is expanding your naked [a-z] and [A-Z] into filename matches so that in effect your&lt;BR /&gt;tr [a-z] [A-Z] becomes tr p ... when a matching file is found.&lt;BR /&gt;&lt;BR /&gt;If you discipline yourself to use ${VAR} rather than $VAR and enclose almost all arguments in the appropriate quotes, you will see far fewer&lt;BR /&gt;unexpected behaviors in the shell.</description>
      <pubDate>Fri, 20 Sep 2002 13:27:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/tr-scripts-giving-wrong-results/m-p/2810478#M84160</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2002-09-20T13:27:21Z</dc:date>
    </item>
  </channel>
</rss>

