Linux Bash Setting Var & Fallback Var Setting With User Input

View previous topic View next topic Go down

Linux Bash Setting Var & Fallback Var Setting With User Input

Post by jamied_uk on 20th July 2016, 11:36




Code:
#!/bin/bash
# Usage: ./if_blank.sh 100
#
var=("$@") # User Input

if [ "$var" = "" ] # Need spaces between brackets!
then : # do something
echo "Var Is Empty, Please Specify A Number"
read var
    echo "Var Is Set To $var"
else
    echo "Var Is Set To $var"
fi
avatar
jamied_uk
Admin

Posts : 2260
Join date : 2010-05-09
Age : 34
Location : UK

http://address-shortner.co.uk

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum