- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: bash & typeset / declare
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
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
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
тАО02-20-2007 11:15 AM
тАО02-20-2007 11:15 AM
Anyway, I am starting to write some bash shell scripts in SLES. The problem I have is that apparently 'typeset -u' is not supported in bash. I am used to using this in HP-UX (Posix shell) to force a variable to be upper case. This is very handy when getting user input.
Is there some functional equivalent to HP-UX 'typeset -u' in bash?
I'm using an awk hack to force the variable to uppercase, but I'd rather not have that extra overhead.
The version of bash I have is:
$ echo $BASH_VERSION
3.1.17(1)-release
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-20-2007 12:12 PM
тАО02-20-2007 12:12 PM
SolutionIt appears that uppercase and lowercase typeset (declare) options don't exist in the Bash shell. You're left with:
# VAR="patrick wallek"
# TOUPPER="$(echo "${VAR}"|tr 'a-z' 'A-Z')"
At least that's probably cheaper than 'awk'.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-20-2007 01:04 PM
тАО02-20-2007 01:04 PM
Re: bash & typeset / declare
I never think about tr for some reason. You're probably right about it being cheaper than awk.
I was doing a bit of research earlier and I do have ksh on SLES and ksh does have the '-u' available in typeset. That could be an option as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-20-2007 02:11 PM
тАО02-20-2007 02:11 PM
Re: bash & typeset / declare
shopt nocaseglob
This tells the inbuilt 'test' ([) to ignore character case in comparisons.
With the 'ksh' options (there's ksh, and pdksh), be careful. From my experience, they aren't 100% compatable with most other ksh versions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-21-2007 12:19 AM
тАО02-21-2007 12:19 AM
Re: bash & typeset / declare
# TOUPPER="$(echo "${VAR}"|tr [:lower:] [:upper:])"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-21-2007 01:14 AM
тАО02-21-2007 01:14 AM
Re: bash & typeset / declare
The really handy thing is the 'shopt' bash built-in.
The "nocaseglob" did not work and on further research (the man page) it appears that nocaseglob is for case-insensitive filename matching.
However, "nocasematch" is what I need. It is used when matching patterns in case statements or when doing tests.
shopt -s nocasematch
causes y to equal Y ; yes = Yes = yEs = yeS = YES
which is what I want.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-21-2007 09:17 AM
тАО02-21-2007 09:17 AM
Re: bash & typeset / declare
There's a reason I print documentation out :P
(0 pts)