Answer the question
In order to leave comments, you need to log in
How to get parameters from file for bash script?
A simple example. We have a script that sends the data received from ifconfig to the file
#!/bin/bash
ifconfig >> myfile
echo "Ok"
As a result, we get something like this in the file:
eth0: flags=4163 mtu 1500
inet 0.0.0.0 netmask 0.0.0.0 broadcast 0.0 0.0.0.0 netmask 0.0.0.0 broadcast 0.0.0.0 TX errors 0
dropped
0 overruns 0 carrier 0 collisions 0
eth3: flags=
4163 mtu 1500
inet 0.0.0.0 netmask 0.0.0.0
inet 0.0.0.0 netmask 0.0.0.0 broadcast 0.0.0.0
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
Actually the question is: how can I get only the name of the available interfaces?
And is it possible to do without writing data from ifconfig to a file?
Answer the question
In order to leave comments, you need to log in
On the knee
Parsing option:
$ ip l|grep mtu|cut -d":" -f 2
lo
eth0
tun0
tap0
br0
tun10
tun1
$ ls /sys/class/net/
br0 eth0 lo tap0 tun0 tun1 tun10
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question