I am asking user for input and taking input in the variables such as $1, $2 etc.I am checking the variable for null value and wants to replace the value if null.if [ $2 ==  ]; then2=valuefiBut something I am missing. Any suggestions?
How to assign value to input variable in shell
shell script;test;variable substitution;parameter
You can't directly set values to the positional paramaters like this.You can set them with the set command, but this will set all the values ($1, $2, ...)e.g.$ set -- first second third fourth fifth$ echo $1first$ echo $2secondNow there are two cases where $2 can be the empty string; first if no value has been passed, or second if  is passed as an actual argument and so there may still be a $3, $4 etc.We can handle each case in a slightly complicated way:#!/bin/bashecho Before 1=$1 2=$2 3=$3 4=$4if [ -z $2 ]then  first=$1  shift 2  set -- $first value $@fiecho After 1=$1 2=$2 3=$3 4=$4The bit inside the if test will ensure all other values are retained.e.g.% ./testing arg1  arg 3 and arg 4Before 1=arg1 2= 3=arg 3 4=and arg 4After 1=arg1 2=value 3=arg 3 4=and arg 4But you might be able to do things simpler and just use ${2:-value} which will evaluate to value if $2 is not set, so then you don't need to worry about rewriting the arguments.