Answer the question
In order to leave comments, you need to log in
How to insert a variable into grep?
how to substitute the mask
variable
in the test=$( echo $ip | grep -o '^ 192.168. ' )
#!/bin/bash
ip="192.168.33.44"
mask="192.168."
test=$(echo $ip | grep -o '^ 192.168. ')
if [ "$test" != "" ];
then echo OK $ip;
else echo BAD
fi;
PS
the meaning of the script
is to check the IP by mask
give yes / no
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question