Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

i have this piece of bash script :

internal=$(/sbin/ifconfig $adapter | grep "inet addr" | awk -F: '{print $2}' | awk '{print $1}')

$adapter="eth0" i want to execute this until internal has the correct value and after that i want to go to the rest of my script Do you have any ideas how i could deal with that ?

After that i have code it in order to send the ip via sms !

Thank you in advance.

share|improve this question
up vote 2 down vote accepted

Try doing this :



until [[ $internal =~ [0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3} ]]; do
    sleep 1
        ifconfig "$adapter" |
        awk -F'(inet add?r:| +|:)' '/inet add?r/{print $3}'

# send sms

As you can see, I use only one pipe : | with , no need more, awk can do the whole processing.

share|improve this answer
It worked greate ! thank you , but it seems there is a litle bug calling my script on the bottom (before "exti 0" of course) of /etc/rc.local , when i receive the sms the time is on 0 unix timestamp :/ NOTE : i receive the sms using my provider's mail (smtp) that send's my the subject on sms – Dimitris Sapikas Apr 3 '13 at 5:50

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.