I need to convert the value of shell variable to uppercase and till now I have done this:
cmd_upper.sh
It seems to work ...
[highlight]... but isn't there a simpler or nicer way how to do it ?[/highlight]
cmd_upper.sh
Code:
[COLOR=#0000ff]#!/usr/bin/qsh[/color]
[COLOR=#0000ff]# convert command line arg to uppercase[/color]
[COLOR=#804040][b]echo[/b][/color][COLOR=#ff00ff] [/color][COLOR=#804040][b]"[/b][/color][COLOR=#ff00ff]original [/color][COLOR=#6a5acd]\$[/color][COLOR=#ff00ff]cmdarg = '[/color][COLOR=#a020f0]$1[/color][COLOR=#ff00ff]'[/color][COLOR=#804040][b]"[/b][/color]
[COLOR=#008080]CMDARG[/color]=[COLOR=#6a5acd]`echo [/color][COLOR=#a020f0]$1[/color][COLOR=#6a5acd] [/color][COLOR=#804040][b]|[/b][/color][COLOR=#6a5acd] tr [/color][COLOR=#804040][b]'[/b][/color][COLOR=#ff00ff][:lower:][/color][COLOR=#804040][b]'[/b][/color][COLOR=#6a5acd] [/color][COLOR=#804040][b]'[/b][/color][COLOR=#ff00ff][:upper:][/color][COLOR=#804040][b]'[/b][/color][COLOR=#6a5acd] [/color][COLOR=#804040][b]|[/b][/color][COLOR=#6a5acd] tr -d [/color][COLOR=#804040][b]'[/b][/color][COLOR=#ff00ff]\n[/color][COLOR=#804040][b]'[/b][/color][COLOR=#6a5acd]`[/color]
[COLOR=#804040][b]echo[/b][/color][COLOR=#ff00ff] [/color][COLOR=#804040][b]"[/b][/color][COLOR=#ff00ff]uppercase [/color][COLOR=#6a5acd]\$[/color][COLOR=#ff00ff]CMDARG = '[/color][COLOR=#a020f0]$CMDARG[/color][COLOR=#ff00ff]'[/color][COLOR=#804040][b]"[/b][/color]
Code:
> cmd_upper.sh myCommandLineArg
original $cmdarg = 'myCommandLineArg'
uppercase $CMDARG = 'MYCOMMANDLINEARG'