Sponsored Content
Full Discussion: Uppercase variable
Top Forums Shell Programming and Scripting Uppercase variable Post 303033931 by jim mcnamara on Sunday 14th of April 2019 08:37:25 PM
Old 04-14-2019
Quote:
Could it be a problem specific comment or in most cases, `` causes issue?
Normally I have been using this though and did not encounter any issue.
No.
The problem relates to nested ``, a pair of back-ticks inside another pair of back-ticks will cause errors.

Quote:
How come would Linux detect uppercase variables as path?
It has nothing to do with PATH particularly. What if you made a variable called "BASH_REMATCH", what would happen? I picked this one because it does not come up very often here on the forums.
Answer: It is the name of an array. Your code could break regular expression searches in bash. None of the special variables bash uses are lowercase.
So, no matter what you do to lowercase variables, you will not mess up shell and other utilities do internally.

This is the output of the set command on my cygwin instance on Windows 7: It's BIG. Many,many variables. If
I use other than default software the variables may increase a lot - Oracle is an example.
Code:
$ set
ALLUSERSPROFILE='C:\ProgramData'
APPDATA='C:\Users\Owner\AppData\Roaming'
BASH=/bin/bash
BASHOPTS=cmdhist:complete_fullquote:expand_aliases:extquote:force_fignore:hostcomplete:interactive_comments:login_shell:progcomp:promptvars:sourcepath
BASH_ALIASES=()
BASH_ARGC=()
BASH_ARGV=()
BASH_CMDS=()
BASH_LINENO=()
BASH_SOURCE=()
BASH_VERSINFO=([0]="4" [1]="4" [2]="12" [3]="3" [4]="release" [5]="x86_64-unknown-cygwin")
BASH_VERSION='4.4.12(3)-release'
COMMONPROGRAMFILES='C:\Program Files\Common Files'
COMPUTERNAME=OWNER-PC
COMSPEC='C:\Windows\system32\cmd.exe'
CYG_SYS_BASHRC=1
CommonProgramW6432='C:\Program Files\Common Files'
DIRSTACK=()
EUID=1000
EXECIGNORE='*.dll'
FP_NO_HOST_CHECK=NO
GROUPS=()
HISTFILE=/home/Owner/.bash_history
HISTFILESIZE=500
HISTSIZE=500
HOME=/home/Owner
HOMEDRIVE=C:
HOMEPATH='\Users\Owner'
HOSTNAME=Owner-PC
HOSTTYPE=x86_64
IFS=$' \t\n'
INFOPATH=/usr/local/info:/usr/share/info:/usr/info
LANG=en_US.UTF-8
LOCALAPPDATA='C:\Users\Owner\AppData\Local'
LOGONSERVER='\\OWNER-PC'
MACHTYPE=x86_64-unknown-cygwin
MAILCHECK=60
MINTTY_SHORTCUT='/cygdrive/c/Users/Public/Desktop/Cygwin64 Terminal.lnk'
NUMBER_OF_PROCESSORS=8
OLDPWD=/cygdrive/c/Users/Owner/Desktop
OPTERR=1
OPTIND=1
ORIGINAL_PATH='/cygdrive/c/ProgramData/Oracle/Java/javapath:/cygdrive/c/Program Files (x86)/Intel/iCLS Client:/cygdrive/c/Program Files/Intel/iCLS Client:/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/Wbem:/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0:/cygdrive/c/Program Files/Intel/Intel(R) Management Engine Components/DAL:/cygdrive/c/Program Files/Intel/Intel(R) Management Engine Components/IPT:/cygdrive/c/Program Files (x86)/Intel/Intel(R) Management Engine Components/DAL:/cygdrive/c/Program Files (x86)/Intel/Intel(R) Management Engine Components/IPT:/cygdrive/c/Program Files (x86)/Intel/OpenCL SDK/2.0/bin/x86:/cygdrive/c/Program Files (x86)/Intel/OpenCL SDK/2.0/bin/x64:/cygdrive/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/Wbem:/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0:/cygdrive/c/Program Files (x86)/Skype/Phone:/cygdrive/c/Users/Owner/.cargo/bin:/cygdrive/c/Users/Owner/AppData/Local/Programs/Python/Python35/Scripts:/cygdrive/c/Users/Owner/AppData/Local/Programs/Python/Python35:/cygdrive/c/Program Files (x86)/IDM Computer Solutions/UltraEdit'
OS=Windows_NT
OSTYPE=cygwin
PATH='/usr/local/bin:/usr/bin:/cygdrive/c/ProgramData/Oracle/Java/javapath:/cygdrive/c/Program Files (x86)/Intel/iCLS Client:/cygdrive/c/Program Files/Intel/iCLS Client:/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/Wbem:/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0:/cygdrive/c/Program Files/Intel/Intel(R) Management Engine Components/DAL:/cygdrive/c/Program Files/Intel/Intel(R) Management Engine Components/IPT:/cygdrive/c/Program Files (x86)/Intel/Intel(R) Management Engine Components/DAL:/cygdrive/c/Program Files (x86)/Intel/Intel(R) Management Engine Components/IPT:/cygdrive/c/Program Files (x86)/Intel/OpenCL SDK/2.0/bin/x86:/cygdrive/c/Program Files (x86)/Intel/OpenCL SDK/2.0/bin/x64:/cygdrive/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/Wbem:/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0:/cygdrive/c/Program Files (x86)/Skype/Phone:/cygdrive/c/Users/Owner/.cargo/bin:/cygdrive/c/Users/Owner/AppData/Local/Programs/Python/Python35/Scripts:/cygdrive/c/Users/Owner/AppData/Local/Programs/Python/Python35:/cygdrive/c/Program Files (x86)/IDM Computer Solutions/UltraEdit:/usr/lib/lapack'
PATHEXT='.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC'
PIPESTATUS=([0]="0")
PPID=35
PRINTER='HP Color LaserJet Pro MFP M477 PCL 6'
PROCESSOR_ARCHITECTURE=AMD64
PROCESSOR_IDENTIFIER='Intel64 Family 6 Model 58 Stepping 9, GenuineIntel'
PROCESSOR_LEVEL=6
PROCESSOR_REVISION=3a09
PROFILEREAD=true
PROGRAMFILES='C:\Program Files'
PS1='\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n\$ '
PS2='> '
PS4='+ '
PSModulePath='C:\Windows\system32\WindowsPowerShell\v1.0\Modules\'
PUBLIC='C:\Users\Public'
PWD=/home/Owner
ProgramData='C:\ProgramData'
ProgramW6432='C:\Program Files'
SESSIONNAME=Console
SHELL=/bin/bash
SHELLOPTS=braceexpand:emacs:hashall:histexpand:history:interactive-comments:monitor
SHLVL=1
SYSTEMDRIVE=C:
SYSTEMROOT='C:\Windows'
TEMP=/tmp
TERM=xterm
TMP=/tmp
TZ=America/Denver
UID=1000
USER=Owner
USERDOMAIN=Owner-PC
USERNAME=Owner
USERPROFILE='C:\Users\Owner'
WINDIR='C:\Windows'
_=env
windows_tracing_flags=3
windows_tracing_logfile='C:\BVTBin\Tests\installpackage\csilogfile.log'
gawklibpath_append ()
{
    [ -z "$AWKLIBPATH" ] && AWKLIBPATH=`gawk 'BEGIN {print ENVIRON["AWKLIBPATH"]}'`;
    export AWKLIBPATH="$AWKLIBPATH:$*"
}
gawklibpath_default ()
{
    unset AWKLIBPATH;
    export AWKLIBPATH=`gawk 'BEGIN {print ENVIRON["AWKLIBPATH"]}'`
}
gawklibpath_prepend ()
{
    [ -z "$AWKLIBPATH" ] && AWKLIBPATH=`gawk 'BEGIN {print ENVIRON["AWKLIBPATH"]}'`;
    export AWKLIBPATH="$*:$AWKLIBPATH"
}
gawkpath_append ()
{
    [ -z "$AWKPATH" ] && AWKPATH=`gawk 'BEGIN {print ENVIRON["AWKPATH"]}'`;
    export AWKPATH="$AWKPATH:$*"
}
gawkpath_default ()
{
    unset AWKPATH;
    export AWKPATH=`gawk 'BEGIN {print ENVIRON["AWKPATH"]}'`
}
gawkpath_prepend ()
{
    [ -z "$AWKPATH" ] && AWKPATH=`gawk 'BEGIN {print ENVIRON["AWKPATH"]}'`;
    export AWKPATH="$*:$AWKPATH"
}
profile_d ()
{
    _LC_ALL_SET_="${LC_ALL+set}";
    _LC_SAVE_="${LC_ALL-null}";
    LC_ALL=C;
    if [ "${_LC_SAVE_}" = "null" ]; then
        for file in /etc/profile.d/*.$1;
        do
            [ -e "${file}" ] && . "${file}";
        done;
        unset LC_ALL;
    else
        for file in /etc/profile.d/*.$1;
        do
            [ -e "${file}" ] && LC_ALL="${_LC_SAVE_}" . "${file}";
        done;
        LC_ALL="${_LC_SAVE_}";
    fi;
    unset file;
    unset _LC_ALL_SET_;
    unset _LC_SAVE_
}

Owner@Owner-PC ~
$


Last edited by jim mcnamara; 04-14-2019 at 09:46 PM..
This User Gave Thanks to jim mcnamara For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

uppercase to lowercase

Greetings & Happy New Years To All! A client of mine FTP'ed their files up to the server and it all ended up being in UPPERCASE when it all should be in lowercase. Is there a builtin command or a script anyone knows of that will automagically convert all files to lowercase? Please advise asap... (4 Replies)
Discussion started by: webex
4 Replies

2. Shell Programming and Scripting

Converting to Uppercase

I want to convert string into uppercase string. How can i do that ? Ex: Enter the user name: read name show=upper(name) echo $show --- This output should be the uppercase output. Thanks (3 Replies)
Discussion started by: dreams5617
3 Replies

3. UNIX for Dummies Questions & Answers

make uppercase

If in a script I am taking an input (R201) for example and assigning it to a variable, how would I change the R to uppercase if it was keyed in as r201? I can't seem to get it to work with toupper (4 Replies)
Discussion started by: kirkm76
4 Replies

4. Shell Programming and Scripting

Conversion to uppercase - tr

Hi, I am trying to convert the $i in loop from lower to upper case but getting error like ' awk: 0602-502 The statement cannot be correctly parsed. The source line is 1.' .. Requirement: I have many table in script XXX.sql which starting with 'ABC_','AbC_','aBc_' etc.. same thing for table... (2 Replies)
Discussion started by: subrat
2 Replies

5. Shell Programming and Scripting

only uppercase first character?

should be a simple question, I am trying to uppercase every first character in a word on the list. abc google cnn services My first thought was sed 'y/^/^/', but it changed all the characters, not just the first character. any thoughts? (7 Replies)
Discussion started by: fedora
7 Replies

6. AIX

Lowercase to Uppercase

Inside a script I have 2 variables COMP=cy and PT=t. further down the same script I require at the same line to call those 2 variables the first time uppercase and after lowercase ${COMP}${PT}ACE,${COMP}${PT}ace. Can somebody help me Thanks in advance George Govotsis (7 Replies)
Discussion started by: ggovotsis
7 Replies

7. UNIX for Dummies Questions & Answers

uppercase to lowercase

i have no variable and no file i just want to convert AJIT to ajit with some command in UNIX can anybody help (4 Replies)
Discussion started by: ajit.yadav83
4 Replies

8. UNIX for Dummies Questions & Answers

UPPERCASE to lowercase

Hi All, i have a file and i want to convert all uppercase letters to lowercase letters which are in my file. how can i do this. Thanx (3 Replies)
Discussion started by: temhem
3 Replies

9. Shell Programming and Scripting

Change to uppercase

Hi I have a string(can be mix of upper and lower case) and need the first three chars of the string to be converted to uppercase (4 Replies)
Discussion started by: Northpole
4 Replies

10. Shell Programming and Scripting

Uppercase to lowercase

Hello, I have a list of files in a directory whose names are all in uppercasse, including the file format for eg *.MP3 . I would like to convert these to the normal way we write it ie ABC.MP3 to be converted to Abc.mp3 . I know that this can be done manually by using a lot of "mv" or rename... (6 Replies)
Discussion started by: ajayram
6 Replies
All times are GMT -4. The time now is 10:53 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy