Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
The problem statement, all variables and given/known data: I am trying to make a script called showtime that displays the current time for a given city.
The problem is on the error checking part im trying to make the script search a directory called zoneinfo to see if the region or city the user entered exist.
Relevant commands, code, scripts, algorithms:
# Declear Varables
region=$1
city=$2 #Checking if region exist in the database
region=$(ls ~/zoneinfo| grep '$1')
The attempts at a solution (include all code and scripts):
# Declear Varables
region=$1
city=$2 #Checking if region exist in the database
region=$(ls ~/zoneinfo| grep '$1')
if [ '$1' == "" ]; then
echo $1 does not exist
exit 2
fi
Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):Seneca College professor name John selmy/course name OPS 435
your website wont let me post the url to the courses sit for some reason??
Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).
with that block of code im trying to make the script search for a region that a user entered which is $1 and see if the region that user entered exists or not
if [[ "$1" = "" ]]; then
echo $1 does not exist
exit 2
fi
but when I run my script showtime with a wrong region it does not show the error message.
ant:/home/vbe/test $ zz Autralia
Autralia does not exist
ant:/home/vbe/test $ zz Australia
Australia
ant:/home/vbe/test $ more zz
#region=$(cat zoneinfo | grep "$1") # Now I understood what you are up to
region=$(ls ~/zoneinfo|grep $1| cut -d"/" -f1) # ln -s to zoneinfo directory...in $HOME
echo $region
if [ "$region" = "" ]
then
echo $1 does not exist
exit 2
fi
zz: END
$1 empty for me means nothing was entered... You say in your last post you are looking for a region...