- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- abnormal execution of "tr" command
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2004 07:04 AM
05-12-2004 07:04 AM
Aharlie
#
# whereis tr
tr: /usr/bin/tr /usr/share/man/man1.Z/tr.1
copied tr executable from another node into /tmp/tr
# diff /usr/bin/tr /tmp/tr
#
(no difference)
# echo abcd | /tmp/tr [a-z] [A-Z]
abAd
OS is hpux 11.11
TIA
UNIX because I majored in cryptology...
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2004 07:14 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2004 07:16 AM
05-12-2004 07:16 AM
Re: abnormal execution of "tr" command
That's extremely odd!! I tried it on my 11i workstation and it came out fine:
root# echo charlie | tr [a-z] [A-Z]
CHARLIE
root# what /usr/bin/tr
/usr/bin/tr:
$Revision: B.11.11_LR
Fri Oct 27 01:01:23 PDT 2000 $
root# uname -a
HP-UX tsws1 B.11.11 U 9000/785 2006183676 unlimited-user license
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2004 07:21 AM
05-12-2004 07:21 AM
Re: abnormal execution of "tr" command
echo "charlie" | tr '[a-z]' '[A-Z]'
I suspect that that will work as expected.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2004 07:30 AM
05-12-2004 07:30 AM
Re: abnormal execution of "tr" command
I can reproduce your error, from my / directory but it works fine in another directory for me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2004 07:39 AM
05-12-2004 07:39 AM
Re: abnormal execution of "tr" command
I am not sure what is causing it but it really bugs me right at the moment. all other 34 servers in my data center responded right to this command but this one. Looks like, for some strange reason, it was hung on lower case c character and thinks that it maps to upper case a, as if my [a-z] [A-Z] mapping does not expand as [abcd...xyz] [ABCD...XYZ].
When I double quoted the [a-z} and [A-Z] expressions, it works. I also tried expanding the sequences by typing all 26 letters in between, this time output turned out to be
# echo abcd | /tmp/tr [abcdefghijklmnopqrstuvwxyz] [ABCDEFGHIJKLMNOPQRSTUVWXYZ]
ab[d
I was running this command as root. When I run it as my mortal userid, i.e., after running su - mortal, it works fine
Also, while I was tying this response andrefreshing the screen to read further responses, yes I changed my working directory of root, which was /root, to / or any other for that matter and the command works fine. Looking at my environment variables, there is nothing fancy about my prompt or any other signficant redirections of any sort.. strange.. but thanks for all the help
Cheers
UNIX because I majored in cryptology...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2004 08:29 AM
05-12-2004 08:29 AM
Re: abnormal execution of "tr" command
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2004 08:39 AM
05-12-2004 08:39 AM
Re: abnormal execution of "tr" command
it has to do with the files in the directory on which the shell tries to perform filename substitution. If you for instance have a file whose name is "c" in the directory, then an expansion could look like this:
# ls [a-z]
c
If you also have e.g. a file named A, then the shell would expand to this:
ls [A-Z]
A
In which case your command would look like this after file name substitution:
# echo charlie | tr c A
Aharlie
It is only a suggestion; you would get a similar result even if you had no file name starting with "A".
Regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2004 09:17 AM
05-12-2004 09:17 AM
Re: abnormal execution of "tr" command
Type the tr command without quotes again, and press ESC twice after typing [a-z] to have the shell expand the string, and do the same for [A-Z]. I assume vi-mode here. Now you can see what is actually being executed.
I wonder what tr will do if more than 1 filename fits. Tr will probably complain; to expand you must type ESC followed by '*'.
I've spent some time on this a few (more than 10) years ago. Always hide wildcards from the shell.
Another example (took half a day to solve):
Don't do: tar xvf /dev/rmt/... /etc/*
if you want to restore the files you removed from /etc. It will only restore files in /etc that are already present because of filename expansion by the shell...
JP