0

On RH 6.7, using bash:

I need to free up some IP addresses using a script.

I am looking for a way to shutdown the bonding using the ifconfig xxx down command.

I search for list of candidate using this:

$ ifconfig |grep ^bond[0-9]:[1-9] |awk '{print $1}'

How may I easily use the output from this command to the down command?

xargs did not work for me:

$ ifconfig |grep ^bond[0-9]:[1-9] |awk '{print \$1}' | xargs -n 1 ifconfig  down

Thanks

Kusalananda
  • 333,661
Alon
  • 1
  • can you post your output of ifconfig in your question? – Rahul Jun 26 '16 at 11:39
  • Why the backslash before $1? – Ralph Rönnquist Jun 26 '16 at 11:49
  • The backslash is for executing it inside a script. – Alon Jun 26 '16 at 12:50
  • ifconfig output: bond0 Link encap:Ethernet HWaddr 2C:59:E5:3F:80:38 inet addr:10.39.234.107 Bcast:10.39.234.255 Mask:255.255.255.0 inet6 addr: fe80::2e59:e5ff:fe3f:8038/64 Scope:Link UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1 RX packets:32018704 errors:0 dropped:0 overruns:0 frame:0 TX packets:29213357 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:2704588477 (2.5 GiB) TX bytes:42021805800 (39.1 GiB) – Alon Jun 26 '16 at 12:51

1 Answers1

-1

Found a nice option:

for i in `ifconfig |grep ^bond[0-9]:[1-9] |awk '{print $1}'` ;   do 
  ifconfig $i down;
done
Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255
Alon
  • 1