mercredi 27 janvier 2021

I wrote the script below to elaborate error occur while using if statement in bash scripting , print if() every time thought it is not true


command : nano test.sh

#!/bin/bash
**echo** "what is your name"
read NAME
***if*** test NAME='pal';then
**echo** "hello pal!"
**echo** "you are owner of this computer."
else 
**echo** "Hello $NAME!"
**echo** "You are not the owner."
***fi***

OUTPUT :

command : sh test.sh

what is your name kevin hello pal! //it has to be run else when if() is incorrect , but here running if() you are owner of this computer.

command : sh test.sh

what is your name pal hello pal! you are owner of this computer.

I am beginner in bash scripting , help me Please ...

Aucun commentaire:

Enregistrer un commentaire