I have written script on bash. It got all list of interfaces. And in loop has compared with variable. But it doesn't work good. My script:
#!/bin/bash search=`ls -1 /sys/class/net | grep -v lo` echo $search eth=eno1 echo $eth for i in $search; do if [ $i == $eth ]; then echo "You choose is: $i" else echo "not found" fi done
In result i have had:
dummy0 eno1 enp4s0 virbr0 virbr0-nic eno1 not found You choose is: eno1 not found not found not found
It is ok. I want, to get one message "You choose is: eno1". If $eth does not contains in "/sys/class/net", i want to get message "not found". Where i have mistake ? Please help. Thank you.