I know this is a very simple task.
And yes, I have used the google search on that topic, but I still dont
get it to work.
I want to check a string by a function, whether that string is a valid
domain adress, assuming, that those consist of 3 parts, which are
divided by dots. The last part may not contain numbers, the other
party may not be empty or have chars other than
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.
I tried
is_domain() {
for i in `echo $* | sed -e 's/\(.\)/\1 /g`
do
case i in [!0-9a-zA-Z]) return 1;;
esac
done
oldifs=$IFS
IFS=.
set "$*"
IFS=$oldifs
for i in `echo $3 | sed -e 's/\(.\)/\1 /g`
do
case i in [a-zA-Z]) return 1;;
esac
done
if is_domain xxx.yyy.xxx
then
...
fi
But it always returns true, even with IPs.
I suppose something with those brackets is wrong.