Hi,
I have a requirement like i have to search a script and find names that conatins more than two dots, if so then throw error.
For ex: a1.b1.comname here i have to find comname and check two dots. it will not throw error
a1.b1.c1.comname here it contains more than 2dots it will throw error.
how i will do this.
Thanks in advance
kurumi
2
$ echo "a1.b1.comname" | ruby -e 'puts gets.count(".")>2 ? "error" : "ok"'
ok
$ echo "a1.b1.c1.comname" | ruby -e 'puts gets.count(".")>2 ? "error" : "ok"'
error
rdcwayx
3
$ echo "a1.b1.comname" |awk -F . '{print (NF>3)?"error":"OK"}'
OK
$ echo "a1.b1.c1.comname" |awk -F . '{print (NF>3)?"error":"OK"}'
error
frans
4
for S in a1.b1.comname a1.b1.c1.comname
do
P=${S//[^.]/}
echo -n "$S : "
[ ${#P} -le 2 ] && echo "OK" || echo "error"
done
Result
a1.b1.comname : OK
a1.b1.c1.comname : error