Reputation: 13652
Basically I have the following script:
#!/bin/bash
echo "What shall we set into managed mode? (e.g. wlan0)"
read thisend
sudo ifconfig $thisend down
sudo iwconfig $thisend mode managed
sudo ifconfig $thisend up
var=$(iwconfig wlan0)
What the script does (as you see) is to set the wireless card into managed mode, but I would like it to double-check at the end of the script if it actually is set in managed mode, which I'll write some comparison system for, but for now I just want to know if it's possible to strip out everything else from the output of iwconfig wlan0
except for Mode: Managed
, and write the remaining output into a new variable.
Upvotes: 2
Views: 88
Reputation: 1188
var = $(iwconfig wlan0 | grep -v 'Mode: Managed')
from grep
man page
-v, --invert-match
Selected lines are those not matching any of the specified patterns.
Upvotes: 2