Ubuntu: wait for network link up and execute a bash command

前端 未结 3 1006
自闭症患者
自闭症患者 2021-01-16 12:28

In Ubuntu (the latest distro is fine), I want to reboot a router and inside a bash script I\'d like to have a command that waits for the network link to be up again and, whe

3条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-16 13:11

    If you want a command to check if the link is up or down use ip :

    ip addr show eth0 | grep -Po "(?<=state ).*?(?=\s)"
    DOWN
    
    ip addr show wlan0 | grep -Po "(?<=state ).*?(?=\s)"
    UP
    

提交回复
热议问题