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















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















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

















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















share|improve this question













share|improve this question




share|improve this question








edited Dec 30 '18 at 8:24









Kulfy

3,97851240




3,97851240










asked Dec 30 '18 at 8:14









susan bhattraisusan bhattrai

11




11




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









        KulfyKulfy

        3,97851240




        3,97851240















            Popular posts from this blog

            flock() on closed filehandle LOCK_FILE at /usr/bin/apt-mirror

            Mangá

            Eduardo VII do Reino Unido