Re: How to detect the number of network adapters installed from kickstart file for network config?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 02/19/2011 04:09 AM, Patrick Lists wrote:
[snip]
Here's how I would try to solve it. Totally untested, use at own risk.
Mind the linewrap. It's all one line. My box has lo, br0, eth0 and
virbr0 so the script should give a total of 4 interfaces.

$ ifconfig -a | grep -vE 'inet|UP|RX|TX|collisions|Interrupt' | awk
'BEGIN {no_of_interfaces=0} /^[a-z]/ {print $1}' | awk 'END
{no_of_interfaces=NR; print "Number of interfaces: " no_of_interfaces}'

Number of interfaces: 4 (correct so apparently this works)

Rereading your question and the script above it greps all interfaces while I think you only need the eth interfaces. If that is the case change /^[a-z]/ to /^eth/

$ ifconfig -a | grep -vE 'inet|UP|RX|TX|collisions|Interrupt' | awk 'BEGIN {no_of_interfaces=0} /^eth/ {print $1}' | awk 'END {no_of_interfaces=NR; print "Number of interfaces: " no_of_interfaces}'

Number of interfaces: 1

Regards,
Patrick

_______________________________________________
Kickstart-list mailing list
Kickstart-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/kickstart-list


[Index of Archives]     [Red Hat General]     [CentOS Users]     [Fedora Users]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux