I am trying to compare two strings but i am having problem [duplicate]












-1















This question already has an answer here:




  • Bash: command not found

    2 answers




read -p 'username : ' usr_value
read -sp 'password : ' psw_value
echo
a=fghj
if["usr_value" = "$a"] #I am having problem in this line
then
echo "you have correct username"
else
echo "you have incorrect username"
if









share|improve this question









New contributor




susan bhattrai is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











marked as duplicate by Sergiy Kolodyazhnyy bash
Users with the  bash badge can single-handedly close bash questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Dec 30 '18 at 8:40


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.











  • 1




    Only use Kali tags while referring to problems specific to Kali. Moreover, Kali is off-topic here.
    – Kulfy
    Dec 30 '18 at 8:26
















-1















This question already has an answer here:




  • Bash: command not found

    2 answers




read -p 'username : ' usr_value
read -sp 'password : ' psw_value
echo
a=fghj
if["usr_value" = "$a"] #I am having problem in this line
then
echo "you have correct username"
else
echo "you have incorrect username"
if









share|improve this question









New contributor




susan bhattrai is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











marked as duplicate by Sergiy Kolodyazhnyy bash
Users with the  bash badge can single-handedly close bash questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Dec 30 '18 at 8:40


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.











  • 1




    Only use Kali tags while referring to problems specific to Kali. Moreover, Kali is off-topic here.
    – Kulfy
    Dec 30 '18 at 8:26














-1












-1








-1








This question already has an answer here:




  • Bash: command not found

    2 answers




read -p 'username : ' usr_value
read -sp 'password : ' psw_value
echo
a=fghj
if["usr_value" = "$a"] #I am having problem in this line
then
echo "you have correct username"
else
echo "you have incorrect username"
if









share|improve this question









New contributor




susan bhattrai is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












This question already has an answer here:




  • Bash: command not found

    2 answers




read -p 'username : ' usr_value
read -sp 'password : ' psw_value
echo
a=fghj
if["usr_value" = "$a"] #I am having problem in this line
then
echo "you have correct username"
else
echo "you have incorrect username"
if




This question already has an answer here:




  • Bash: command not found

    2 answers








bash






share|improve this question









New contributor




susan bhattrai is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




susan bhattrai is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited Dec 30 '18 at 8:24









Kulfy

3,49341139




3,49341139






New contributor




susan bhattrai is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Dec 30 '18 at 8:14









susan bhattrai

11




11




New contributor




susan bhattrai is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





susan bhattrai is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






susan bhattrai is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




marked as duplicate by Sergiy Kolodyazhnyy bash
Users with the  bash badge can single-handedly close bash questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Dec 30 '18 at 8:40


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






marked as duplicate by Sergiy Kolodyazhnyy bash
Users with the  bash badge can single-handedly close bash questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Dec 30 '18 at 8:40


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.










  • 1




    Only use Kali tags while referring to problems specific to Kali. Moreover, Kali is off-topic here.
    – Kulfy
    Dec 30 '18 at 8:26














  • 1




    Only use Kali tags while referring to problems specific to Kali. Moreover, Kali is off-topic here.
    – Kulfy
    Dec 30 '18 at 8:26








1




1




Only use Kali tags while referring to problems specific to Kali. Moreover, Kali is off-topic here.
– Kulfy
Dec 30 '18 at 8:26




Only use Kali tags while referring to problems specific to Kali. Moreover, Kali is off-topic here.
– Kulfy
Dec 30 '18 at 8:26










1 Answer
1






active

oldest

votes


















2














Here I see two problems,





  1. Syntax of if: You seem to have not followed the proper syntax. It must be like



    if [ <condition> ] #mind the whitespaces


    Moreover you need to compare values of usr_value and a not value of a with usr_value as a value, i.e. in your code usr_value is being treated as a string value not a variable. So, it should be like



    if [ "$usr_value" = "$a" ]


  2. if else should be ended with fi but you have used if again in the end of if else statements.







share|improve this answer






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2














    Here I see two problems,





    1. Syntax of if: You seem to have not followed the proper syntax. It must be like



      if [ <condition> ] #mind the whitespaces


      Moreover you need to compare values of usr_value and a not value of a with usr_value as a value, i.e. in your code usr_value is being treated as a string value not a variable. So, it should be like



      if [ "$usr_value" = "$a" ]


    2. if else should be ended with fi but you have used if again in the end of if else statements.







    share|improve this answer




























      2














      Here I see two problems,





      1. Syntax of if: You seem to have not followed the proper syntax. It must be like



        if [ <condition> ] #mind the whitespaces


        Moreover you need to compare values of usr_value and a not value of a with usr_value as a value, i.e. in your code usr_value is being treated as a string value not a variable. So, it should be like



        if [ "$usr_value" = "$a" ]


      2. if else should be ended with fi but you have used if again in the end of if else statements.







      share|improve this answer


























        2












        2








        2






        Here I see two problems,





        1. Syntax of if: You seem to have not followed the proper syntax. It must be like



          if [ <condition> ] #mind the whitespaces


          Moreover you need to compare values of usr_value and a not value of a with usr_value as a value, i.e. in your code usr_value is being treated as a string value not a variable. So, it should be like



          if [ "$usr_value" = "$a" ]


        2. if else should be ended with fi but you have used if again in the end of if else statements.







        share|improve this answer














        Here I see two problems,





        1. Syntax of if: You seem to have not followed the proper syntax. It must be like



          if [ <condition> ] #mind the whitespaces


          Moreover you need to compare values of usr_value and a not value of a with usr_value as a value, i.e. in your code usr_value is being treated as a string value not a variable. So, it should be like



          if [ "$usr_value" = "$a" ]


        2. if else should be ended with fi but you have used if again in the end of if else statements.








        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Dec 30 '18 at 8:39

























        answered Dec 30 '18 at 8:33









        Kulfy

        3,49341139




        3,49341139















            Popular posts from this blog

            How to make a Squid Proxy server?

            Is this a new Fibonacci Identity?

            19世紀