Trying to use the read command to accept user input from the command prompt itself but my script doesnt seem to be moving forwardecho Do you want to continue?(yes/no)read -p $1if [ $1 == yes ]thensleep 5secho echo  move aheadelse    echo     echo Skipping The Step..    echo sleep 5sfiI want to execute the script like this..sh script.sh yessh script.sh no  Added a -p to the above script and all seems to work very well. This is my real problem. I have another script test.sh which calls script.sh. So this is how i put the input  cat  test.sh yes#!/bin/bashecho execute the below scriptsh script.sh $1sh test.sh yes  This way doesnt work as the script picks up a default no and moves ahead. Any ideas.
Read Input From Command Line
bash;shell script;shell
$1,$2  - command line positional arguments and couldn't be assigned like read [-p] $1 or any other way except set -- firsr_arg second_arg For your case it can be test if arguments is present then test themwhile [ -z $REPLY ] ; do    if [ -z $1 ] ; then         read -p Do you want to continue?(yes/no)     else         REPLY=$1         set --    fi    case $REPLY in        [Yy]es) sleep 5s                echo -e \n move ahead ;;         [Nn]o) echo -e \nSkipping The Step..\n                sleep 5s ;;             *) echo Wrong answer. Print 'yes' or 'no'                 unset REPLY ;;    esacdone