converting to lower case or upper case

here is a code

column_name="vivek"
column_name2="ViVeK"
column_name=$(echo  $column_name | awk '{print tolower($0)}')
column_name2=$(echo  $column_name2 | awk '{print tolower($0)}')

                       echo "column name 1 lower: $column_name"
                        echo "column name 2 lower: $coulmn_name2"
 
if [[ "$column_name" = "$column_name2" ]]
then
        echo "matching"
fi

but the output is showing as matching even though the output of column_name2 is null... i think the syntax for converting to lower case or upper case is not working.. i even tried typeset -u column_name but this syntax is not working... plz help me out.... :wall::wall:

why don't use sed or tr?

column_name="vivek"
column_name2="ViVeK"
column_name=$(echo  $column_name | tr '[:upper:]' '[:lower:]')
column_name2=$(echo  $column_name2 | tr '[:upper:]' '[:lower:]')

                       echo "column name 1 lower: $column_name"
                        echo "column name 2 lower: $coulmn_name2"
  
# I think maybe you should use double equal sign
if [[ "$column_name" == "$column_name2" ]]
then
        echo "matching"
fi
1 Like

i dont have much knowledge on sed or tr.. :-(... thanks for replying but still same issue is persisitng.. the output which i got is

column name 1 lower: vivek
column name 2 lower:
matching

the column_name2 is not printed again....this is the same output which i got previously

I think, that's because of the typo.

echo "column name 2 lower: $coulmn_name2

it should be.

 echo "column name 2 lower: $column_name2 
1 Like

what is the difference between last two lines...? both are same right..

---------- Post updated at 11:28 AM ---------- Previous update was at 11:26 AM ----------

hey got the output.. thanks :slight_smile: but what was the typo...? is it the italised characters.. coz when i copy pasted the last line it worked :slight_smile: thanks a lot

---------- Post updated at 11:35 AM ---------- Previous update was at 11:28 AM ----------

.. :frowning: :frowning: i had used the above code in a lengthy code of mine there its not working again.... but when i used the same code independently in a script its working.... do you have any alternative like tr or sed?

Hi vivek,

check the 2 bold words correctly, they two are not same and the second statement worked not because of italised...

oh okay thanks :slight_smile: