0
#!/bin/sh
read name
if test "$name"=akash
then 
echo "Hello how are you"
else
echo "sorry"

This is my script but at both case I am getting "Hello how are you" response

jww
  • 97,681
  • 90
  • 411
  • 885
  • 1
    Looks like Cargo-cult programming, thanks to read doc FAQ: http://mywiki.wooledge.org/BashFAQ | Guide: http://mywiki.wooledge.org/BashGuide | Ref: http://gnu.org/s/bash/manual | http://wiki.bash-hackers.org/ | http://mywiki.wooledge.org/Quotes | Check your script: http://www.shellcheck.net/ – Gilles Quénot Mar 29 '18 at 17:45
  • `test "$name" = akash` -- spaces are important. – Charles Duffy Mar 29 '18 at 17:45
  • Maybe not worst to end with `if` and indenting code properly. Indenting is like showing a bit of respect for readers and deserve clarity/readability... – Gilles Quénot Mar 29 '18 at 17:54

1 Answers1

0

You are testing if the single string "$name"=akash is empty or not. You need spaces around the = so that test sees three separate arguments.

if test "$name" = akash
then
chepner
  • 497,756
  • 71
  • 530
  • 681