A Unix AIX variable without a $ symbol?












3















I'm trying to debug an existing program and found an if condition without $ symbol prefixed to it.



Values are:



dt_val=1234
prev_dt_val=1234


If condition goes like:



if [ dt_val -eq prev_dt_val ]
then
echo "Equal"
else
echo "Not equal"
fi

Result:
Equal


Anyone throw some light on how the condition is working fine without a $ symbol?

Shouldn't that be..?



[ $dt_val -eq $prev_dt_val ]


The same condition fails when comparing string values. Does that mean, this condition does not require a $ symbol for number?



Additional info:

Comparing Strings with == as suggested:



dt_val="abcd"
prev_dt_val="abcd"

if [ dt_val == prev_dt_val ]
> then
> echo Equal
> else
> echo Not equal
> fi
Not equal


Shell Info:



echo $SHELL
/usr/bin/ksh
Version M-11/16/88f


Wondering why there's no error either.










share|improve this question

























  • It might help illustrate the situation better if you demonstrate unequal values comparing (successfully) as unequal, without $

    – Jeff Schaller
    Jan 15 at 13:55











  • Really similar, but talks about [[ instead of [ -- unix.stackexchange.com/q/244685/117549

    – Jeff Schaller
    Jan 15 at 14:02











  • If I was to guess, ksh is using the same code as [[ and is performing variable expansion "for" you.

    – Jeff Schaller
    Jan 15 at 14:22











  • Could you split the question into separate examples of string versus numeric values for testing? Using -eq would be wrong for strings (use = or != for strings).

    – Jeff Schaller
    Jan 15 at 14:41






  • 1





    The [ is a built-in command, and it may treat the -eq test as a proper arithmetic context. $ is not needed on variables in an arithmetic context.

    – Kusalananda
    Jan 15 at 16:14
















3















I'm trying to debug an existing program and found an if condition without $ symbol prefixed to it.



Values are:



dt_val=1234
prev_dt_val=1234


If condition goes like:



if [ dt_val -eq prev_dt_val ]
then
echo "Equal"
else
echo "Not equal"
fi

Result:
Equal


Anyone throw some light on how the condition is working fine without a $ symbol?

Shouldn't that be..?



[ $dt_val -eq $prev_dt_val ]


The same condition fails when comparing string values. Does that mean, this condition does not require a $ symbol for number?



Additional info:

Comparing Strings with == as suggested:



dt_val="abcd"
prev_dt_val="abcd"

if [ dt_val == prev_dt_val ]
> then
> echo Equal
> else
> echo Not equal
> fi
Not equal


Shell Info:



echo $SHELL
/usr/bin/ksh
Version M-11/16/88f


Wondering why there's no error either.










share|improve this question

























  • It might help illustrate the situation better if you demonstrate unequal values comparing (successfully) as unequal, without $

    – Jeff Schaller
    Jan 15 at 13:55











  • Really similar, but talks about [[ instead of [ -- unix.stackexchange.com/q/244685/117549

    – Jeff Schaller
    Jan 15 at 14:02











  • If I was to guess, ksh is using the same code as [[ and is performing variable expansion "for" you.

    – Jeff Schaller
    Jan 15 at 14:22











  • Could you split the question into separate examples of string versus numeric values for testing? Using -eq would be wrong for strings (use = or != for strings).

    – Jeff Schaller
    Jan 15 at 14:41






  • 1





    The [ is a built-in command, and it may treat the -eq test as a proper arithmetic context. $ is not needed on variables in an arithmetic context.

    – Kusalananda
    Jan 15 at 16:14














3












3








3








I'm trying to debug an existing program and found an if condition without $ symbol prefixed to it.



Values are:



dt_val=1234
prev_dt_val=1234


If condition goes like:



if [ dt_val -eq prev_dt_val ]
then
echo "Equal"
else
echo "Not equal"
fi

Result:
Equal


Anyone throw some light on how the condition is working fine without a $ symbol?

Shouldn't that be..?



[ $dt_val -eq $prev_dt_val ]


The same condition fails when comparing string values. Does that mean, this condition does not require a $ symbol for number?



Additional info:

Comparing Strings with == as suggested:



dt_val="abcd"
prev_dt_val="abcd"

if [ dt_val == prev_dt_val ]
> then
> echo Equal
> else
> echo Not equal
> fi
Not equal


Shell Info:



echo $SHELL
/usr/bin/ksh
Version M-11/16/88f


Wondering why there's no error either.










share|improve this question
















I'm trying to debug an existing program and found an if condition without $ symbol prefixed to it.



Values are:



dt_val=1234
prev_dt_val=1234


If condition goes like:



if [ dt_val -eq prev_dt_val ]
then
echo "Equal"
else
echo "Not equal"
fi

Result:
Equal


Anyone throw some light on how the condition is working fine without a $ symbol?

Shouldn't that be..?



[ $dt_val -eq $prev_dt_val ]


The same condition fails when comparing string values. Does that mean, this condition does not require a $ symbol for number?



Additional info:

Comparing Strings with == as suggested:



dt_val="abcd"
prev_dt_val="abcd"

if [ dt_val == prev_dt_val ]
> then
> echo Equal
> else
> echo Not equal
> fi
Not equal


Shell Info:



echo $SHELL
/usr/bin/ksh
Version M-11/16/88f


Wondering why there's no error either.







variable ksh aix test numeric-data






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 15 at 15:00







Santhosh Ram

















asked Jan 15 at 13:35









Santhosh RamSanthosh Ram

235




235













  • It might help illustrate the situation better if you demonstrate unequal values comparing (successfully) as unequal, without $

    – Jeff Schaller
    Jan 15 at 13:55











  • Really similar, but talks about [[ instead of [ -- unix.stackexchange.com/q/244685/117549

    – Jeff Schaller
    Jan 15 at 14:02











  • If I was to guess, ksh is using the same code as [[ and is performing variable expansion "for" you.

    – Jeff Schaller
    Jan 15 at 14:22











  • Could you split the question into separate examples of string versus numeric values for testing? Using -eq would be wrong for strings (use = or != for strings).

    – Jeff Schaller
    Jan 15 at 14:41






  • 1





    The [ is a built-in command, and it may treat the -eq test as a proper arithmetic context. $ is not needed on variables in an arithmetic context.

    – Kusalananda
    Jan 15 at 16:14



















  • It might help illustrate the situation better if you demonstrate unequal values comparing (successfully) as unequal, without $

    – Jeff Schaller
    Jan 15 at 13:55











  • Really similar, but talks about [[ instead of [ -- unix.stackexchange.com/q/244685/117549

    – Jeff Schaller
    Jan 15 at 14:02











  • If I was to guess, ksh is using the same code as [[ and is performing variable expansion "for" you.

    – Jeff Schaller
    Jan 15 at 14:22











  • Could you split the question into separate examples of string versus numeric values for testing? Using -eq would be wrong for strings (use = or != for strings).

    – Jeff Schaller
    Jan 15 at 14:41






  • 1





    The [ is a built-in command, and it may treat the -eq test as a proper arithmetic context. $ is not needed on variables in an arithmetic context.

    – Kusalananda
    Jan 15 at 16:14

















It might help illustrate the situation better if you demonstrate unequal values comparing (successfully) as unequal, without $

– Jeff Schaller
Jan 15 at 13:55





It might help illustrate the situation better if you demonstrate unequal values comparing (successfully) as unequal, without $

– Jeff Schaller
Jan 15 at 13:55













Really similar, but talks about [[ instead of [ -- unix.stackexchange.com/q/244685/117549

– Jeff Schaller
Jan 15 at 14:02





Really similar, but talks about [[ instead of [ -- unix.stackexchange.com/q/244685/117549

– Jeff Schaller
Jan 15 at 14:02













If I was to guess, ksh is using the same code as [[ and is performing variable expansion "for" you.

– Jeff Schaller
Jan 15 at 14:22





If I was to guess, ksh is using the same code as [[ and is performing variable expansion "for" you.

– Jeff Schaller
Jan 15 at 14:22













Could you split the question into separate examples of string versus numeric values for testing? Using -eq would be wrong for strings (use = or != for strings).

– Jeff Schaller
Jan 15 at 14:41





Could you split the question into separate examples of string versus numeric values for testing? Using -eq would be wrong for strings (use = or != for strings).

– Jeff Schaller
Jan 15 at 14:41




1




1





The [ is a built-in command, and it may treat the -eq test as a proper arithmetic context. $ is not needed on variables in an arithmetic context.

– Kusalananda
Jan 15 at 16:14





The [ is a built-in command, and it may treat the -eq test as a proper arithmetic context. $ is not needed on variables in an arithmetic context.

– Kusalananda
Jan 15 at 16:14










2 Answers
2






active

oldest

votes


















4














In ksh, the builtin [ takes the operands of -eq as in an arithmetic context, just like Bash does for [[ and -eq. And in an arithmetic context, variables don't need the $ sign.



$ ksh -c 'a=1 b=1; if [ a -eq b ]; then echo equal; else echo different; fi'
equal
$ ksh -c 'a=1 b=2; if [ a -eq b ]; then echo equal; else echo different; fi'
different


or even:



$ ksh -c 'a=2 b=8; if [ a*4 -eq b ]; then echo equal; else echo different; fi'
equal
$ ksh -c 'a=2 b=9; if [ a*4 -eq b ]; then echo equal; else echo different; fi'
different


(However, the * still globs, so a*4 should be quoted there.)



That's ksh93, ksh --version shows sh (AT&T Research) 93u+ 2012-08-01, it's from Debian's package (ksh, package version 93u+20120801-3.1). I get the same result with Debian's mksh, so I suppose ksh88 is close enough here.





For comparison, in Bash that gives an error:



$ bash -c 'a=1 b=1; if [ a -eq b ]; then echo equal; else echo different; fi'
bash: line 0: [: a: integer expression expected
different


(it prints different, since [ returns a falsy value on error).



With [[ it works:



$ bash -c 'a=1 b=1; if [[ a -eq b ]]; then echo equal; else echo different; fi'
equal


Zsh is like Bash here, [ errors on a -eq b, [[ works.






share|improve this answer

































    0














    Firstly, the script is not evaluatling the variables as it's missing the $ in front of the variable names, like you also discovered.



    Secondly, it's outputting "Equal" because it's using the numeric compare operator -eq in the test ([) command. As it's passed two non-numerical strings as parameters, they both evaluate to the same numeric value and hence the "Equal" string is output.



    Note that at least by bash version complains:



    $ if [ 0 -eq bla ]; then echo yes; fi
    -bash: [: bla: integer expression expected


    My dash version also complains:



    $ if [ 0 -eq bla ]; then echo yes; fi
    dash: 1: [: Illegal number: bla


    I'm interested what shell you are using that doesn't complain.



    Even if there are variables present with the names of those strings I get the same result.






    share|improve this answer
























    • but if you set dt_val=5, the test fails...

      – Jeff Schaller
      Jan 15 at 13:55











    • I'm using ksh. It gives me the error when i'm comparing string values such as "abcd" ksh: abcd: 0403-009 The specified number is not valid for this command

      – Santhosh Ram
      Jan 15 at 14:11













    • @JeffSchaller, No, it's not failing for me. I get the result as Equal

      – Santhosh Ram
      Jan 15 at 14:12











    • dt_val=5 prev_dt_val=6 if [ dt_val -eq prev_dt_val ] then echo equal else echo not equal fi not equal

      – Santhosh Ram
      Jan 15 at 14:15













    • @SanthoshRam what version of ksh?

      – Jeff Schaller
      Jan 15 at 14:23











    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "106"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f494607%2fa-unix-aix-variable-without-a-symbol%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    4














    In ksh, the builtin [ takes the operands of -eq as in an arithmetic context, just like Bash does for [[ and -eq. And in an arithmetic context, variables don't need the $ sign.



    $ ksh -c 'a=1 b=1; if [ a -eq b ]; then echo equal; else echo different; fi'
    equal
    $ ksh -c 'a=1 b=2; if [ a -eq b ]; then echo equal; else echo different; fi'
    different


    or even:



    $ ksh -c 'a=2 b=8; if [ a*4 -eq b ]; then echo equal; else echo different; fi'
    equal
    $ ksh -c 'a=2 b=9; if [ a*4 -eq b ]; then echo equal; else echo different; fi'
    different


    (However, the * still globs, so a*4 should be quoted there.)



    That's ksh93, ksh --version shows sh (AT&T Research) 93u+ 2012-08-01, it's from Debian's package (ksh, package version 93u+20120801-3.1). I get the same result with Debian's mksh, so I suppose ksh88 is close enough here.





    For comparison, in Bash that gives an error:



    $ bash -c 'a=1 b=1; if [ a -eq b ]; then echo equal; else echo different; fi'
    bash: line 0: [: a: integer expression expected
    different


    (it prints different, since [ returns a falsy value on error).



    With [[ it works:



    $ bash -c 'a=1 b=1; if [[ a -eq b ]]; then echo equal; else echo different; fi'
    equal


    Zsh is like Bash here, [ errors on a -eq b, [[ works.






    share|improve this answer






























      4














      In ksh, the builtin [ takes the operands of -eq as in an arithmetic context, just like Bash does for [[ and -eq. And in an arithmetic context, variables don't need the $ sign.



      $ ksh -c 'a=1 b=1; if [ a -eq b ]; then echo equal; else echo different; fi'
      equal
      $ ksh -c 'a=1 b=2; if [ a -eq b ]; then echo equal; else echo different; fi'
      different


      or even:



      $ ksh -c 'a=2 b=8; if [ a*4 -eq b ]; then echo equal; else echo different; fi'
      equal
      $ ksh -c 'a=2 b=9; if [ a*4 -eq b ]; then echo equal; else echo different; fi'
      different


      (However, the * still globs, so a*4 should be quoted there.)



      That's ksh93, ksh --version shows sh (AT&T Research) 93u+ 2012-08-01, it's from Debian's package (ksh, package version 93u+20120801-3.1). I get the same result with Debian's mksh, so I suppose ksh88 is close enough here.





      For comparison, in Bash that gives an error:



      $ bash -c 'a=1 b=1; if [ a -eq b ]; then echo equal; else echo different; fi'
      bash: line 0: [: a: integer expression expected
      different


      (it prints different, since [ returns a falsy value on error).



      With [[ it works:



      $ bash -c 'a=1 b=1; if [[ a -eq b ]]; then echo equal; else echo different; fi'
      equal


      Zsh is like Bash here, [ errors on a -eq b, [[ works.






      share|improve this answer




























        4












        4








        4







        In ksh, the builtin [ takes the operands of -eq as in an arithmetic context, just like Bash does for [[ and -eq. And in an arithmetic context, variables don't need the $ sign.



        $ ksh -c 'a=1 b=1; if [ a -eq b ]; then echo equal; else echo different; fi'
        equal
        $ ksh -c 'a=1 b=2; if [ a -eq b ]; then echo equal; else echo different; fi'
        different


        or even:



        $ ksh -c 'a=2 b=8; if [ a*4 -eq b ]; then echo equal; else echo different; fi'
        equal
        $ ksh -c 'a=2 b=9; if [ a*4 -eq b ]; then echo equal; else echo different; fi'
        different


        (However, the * still globs, so a*4 should be quoted there.)



        That's ksh93, ksh --version shows sh (AT&T Research) 93u+ 2012-08-01, it's from Debian's package (ksh, package version 93u+20120801-3.1). I get the same result with Debian's mksh, so I suppose ksh88 is close enough here.





        For comparison, in Bash that gives an error:



        $ bash -c 'a=1 b=1; if [ a -eq b ]; then echo equal; else echo different; fi'
        bash: line 0: [: a: integer expression expected
        different


        (it prints different, since [ returns a falsy value on error).



        With [[ it works:



        $ bash -c 'a=1 b=1; if [[ a -eq b ]]; then echo equal; else echo different; fi'
        equal


        Zsh is like Bash here, [ errors on a -eq b, [[ works.






        share|improve this answer















        In ksh, the builtin [ takes the operands of -eq as in an arithmetic context, just like Bash does for [[ and -eq. And in an arithmetic context, variables don't need the $ sign.



        $ ksh -c 'a=1 b=1; if [ a -eq b ]; then echo equal; else echo different; fi'
        equal
        $ ksh -c 'a=1 b=2; if [ a -eq b ]; then echo equal; else echo different; fi'
        different


        or even:



        $ ksh -c 'a=2 b=8; if [ a*4 -eq b ]; then echo equal; else echo different; fi'
        equal
        $ ksh -c 'a=2 b=9; if [ a*4 -eq b ]; then echo equal; else echo different; fi'
        different


        (However, the * still globs, so a*4 should be quoted there.)



        That's ksh93, ksh --version shows sh (AT&T Research) 93u+ 2012-08-01, it's from Debian's package (ksh, package version 93u+20120801-3.1). I get the same result with Debian's mksh, so I suppose ksh88 is close enough here.





        For comparison, in Bash that gives an error:



        $ bash -c 'a=1 b=1; if [ a -eq b ]; then echo equal; else echo different; fi'
        bash: line 0: [: a: integer expression expected
        different


        (it prints different, since [ returns a falsy value on error).



        With [[ it works:



        $ bash -c 'a=1 b=1; if [[ a -eq b ]]; then echo equal; else echo different; fi'
        equal


        Zsh is like Bash here, [ errors on a -eq b, [[ works.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Jan 15 at 21:02

























        answered Jan 15 at 20:38









        ilkkachuilkkachu

        56.9k785158




        56.9k785158

























            0














            Firstly, the script is not evaluatling the variables as it's missing the $ in front of the variable names, like you also discovered.



            Secondly, it's outputting "Equal" because it's using the numeric compare operator -eq in the test ([) command. As it's passed two non-numerical strings as parameters, they both evaluate to the same numeric value and hence the "Equal" string is output.



            Note that at least by bash version complains:



            $ if [ 0 -eq bla ]; then echo yes; fi
            -bash: [: bla: integer expression expected


            My dash version also complains:



            $ if [ 0 -eq bla ]; then echo yes; fi
            dash: 1: [: Illegal number: bla


            I'm interested what shell you are using that doesn't complain.



            Even if there are variables present with the names of those strings I get the same result.






            share|improve this answer
























            • but if you set dt_val=5, the test fails...

              – Jeff Schaller
              Jan 15 at 13:55











            • I'm using ksh. It gives me the error when i'm comparing string values such as "abcd" ksh: abcd: 0403-009 The specified number is not valid for this command

              – Santhosh Ram
              Jan 15 at 14:11













            • @JeffSchaller, No, it's not failing for me. I get the result as Equal

              – Santhosh Ram
              Jan 15 at 14:12











            • dt_val=5 prev_dt_val=6 if [ dt_val -eq prev_dt_val ] then echo equal else echo not equal fi not equal

              – Santhosh Ram
              Jan 15 at 14:15













            • @SanthoshRam what version of ksh?

              – Jeff Schaller
              Jan 15 at 14:23
















            0














            Firstly, the script is not evaluatling the variables as it's missing the $ in front of the variable names, like you also discovered.



            Secondly, it's outputting "Equal" because it's using the numeric compare operator -eq in the test ([) command. As it's passed two non-numerical strings as parameters, they both evaluate to the same numeric value and hence the "Equal" string is output.



            Note that at least by bash version complains:



            $ if [ 0 -eq bla ]; then echo yes; fi
            -bash: [: bla: integer expression expected


            My dash version also complains:



            $ if [ 0 -eq bla ]; then echo yes; fi
            dash: 1: [: Illegal number: bla


            I'm interested what shell you are using that doesn't complain.



            Even if there are variables present with the names of those strings I get the same result.






            share|improve this answer
























            • but if you set dt_val=5, the test fails...

              – Jeff Schaller
              Jan 15 at 13:55











            • I'm using ksh. It gives me the error when i'm comparing string values such as "abcd" ksh: abcd: 0403-009 The specified number is not valid for this command

              – Santhosh Ram
              Jan 15 at 14:11













            • @JeffSchaller, No, it's not failing for me. I get the result as Equal

              – Santhosh Ram
              Jan 15 at 14:12











            • dt_val=5 prev_dt_val=6 if [ dt_val -eq prev_dt_val ] then echo equal else echo not equal fi not equal

              – Santhosh Ram
              Jan 15 at 14:15













            • @SanthoshRam what version of ksh?

              – Jeff Schaller
              Jan 15 at 14:23














            0












            0








            0







            Firstly, the script is not evaluatling the variables as it's missing the $ in front of the variable names, like you also discovered.



            Secondly, it's outputting "Equal" because it's using the numeric compare operator -eq in the test ([) command. As it's passed two non-numerical strings as parameters, they both evaluate to the same numeric value and hence the "Equal" string is output.



            Note that at least by bash version complains:



            $ if [ 0 -eq bla ]; then echo yes; fi
            -bash: [: bla: integer expression expected


            My dash version also complains:



            $ if [ 0 -eq bla ]; then echo yes; fi
            dash: 1: [: Illegal number: bla


            I'm interested what shell you are using that doesn't complain.



            Even if there are variables present with the names of those strings I get the same result.






            share|improve this answer













            Firstly, the script is not evaluatling the variables as it's missing the $ in front of the variable names, like you also discovered.



            Secondly, it's outputting "Equal" because it's using the numeric compare operator -eq in the test ([) command. As it's passed two non-numerical strings as parameters, they both evaluate to the same numeric value and hence the "Equal" string is output.



            Note that at least by bash version complains:



            $ if [ 0 -eq bla ]; then echo yes; fi
            -bash: [: bla: integer expression expected


            My dash version also complains:



            $ if [ 0 -eq bla ]; then echo yes; fi
            dash: 1: [: Illegal number: bla


            I'm interested what shell you are using that doesn't complain.



            Even if there are variables present with the names of those strings I get the same result.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Jan 15 at 13:49









            wurtelwurtel

            10.3k11426




            10.3k11426













            • but if you set dt_val=5, the test fails...

              – Jeff Schaller
              Jan 15 at 13:55











            • I'm using ksh. It gives me the error when i'm comparing string values such as "abcd" ksh: abcd: 0403-009 The specified number is not valid for this command

              – Santhosh Ram
              Jan 15 at 14:11













            • @JeffSchaller, No, it's not failing for me. I get the result as Equal

              – Santhosh Ram
              Jan 15 at 14:12











            • dt_val=5 prev_dt_val=6 if [ dt_val -eq prev_dt_val ] then echo equal else echo not equal fi not equal

              – Santhosh Ram
              Jan 15 at 14:15













            • @SanthoshRam what version of ksh?

              – Jeff Schaller
              Jan 15 at 14:23



















            • but if you set dt_val=5, the test fails...

              – Jeff Schaller
              Jan 15 at 13:55











            • I'm using ksh. It gives me the error when i'm comparing string values such as "abcd" ksh: abcd: 0403-009 The specified number is not valid for this command

              – Santhosh Ram
              Jan 15 at 14:11













            • @JeffSchaller, No, it's not failing for me. I get the result as Equal

              – Santhosh Ram
              Jan 15 at 14:12











            • dt_val=5 prev_dt_val=6 if [ dt_val -eq prev_dt_val ] then echo equal else echo not equal fi not equal

              – Santhosh Ram
              Jan 15 at 14:15













            • @SanthoshRam what version of ksh?

              – Jeff Schaller
              Jan 15 at 14:23

















            but if you set dt_val=5, the test fails...

            – Jeff Schaller
            Jan 15 at 13:55





            but if you set dt_val=5, the test fails...

            – Jeff Schaller
            Jan 15 at 13:55













            I'm using ksh. It gives me the error when i'm comparing string values such as "abcd" ksh: abcd: 0403-009 The specified number is not valid for this command

            – Santhosh Ram
            Jan 15 at 14:11







            I'm using ksh. It gives me the error when i'm comparing string values such as "abcd" ksh: abcd: 0403-009 The specified number is not valid for this command

            – Santhosh Ram
            Jan 15 at 14:11















            @JeffSchaller, No, it's not failing for me. I get the result as Equal

            – Santhosh Ram
            Jan 15 at 14:12





            @JeffSchaller, No, it's not failing for me. I get the result as Equal

            – Santhosh Ram
            Jan 15 at 14:12













            dt_val=5 prev_dt_val=6 if [ dt_val -eq prev_dt_val ] then echo equal else echo not equal fi not equal

            – Santhosh Ram
            Jan 15 at 14:15







            dt_val=5 prev_dt_val=6 if [ dt_val -eq prev_dt_val ] then echo equal else echo not equal fi not equal

            – Santhosh Ram
            Jan 15 at 14:15















            @SanthoshRam what version of ksh?

            – Jeff Schaller
            Jan 15 at 14:23





            @SanthoshRam what version of ksh?

            – Jeff Schaller
            Jan 15 at 14:23


















            draft saved

            draft discarded




















































            Thanks for contributing an answer to Unix & Linux Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f494607%2fa-unix-aix-variable-without-a-symbol%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            How to make a Squid Proxy server?

            Is this a new Fibonacci Identity?

            19世紀