awk refactor of my scripts
awk is OP man - so easy to use and does a bunch of stuff all at once without having to rely on multiple pipes. It comes with essentially every distribution so you'll always have access to it.
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
internet=$(nmcli g | sed -n 2p | awk '{print $1}')
|
||||
internet=$(nmcli g | awk 'NR == 2 {print $1}')
|
||||
if [[ $internet == "connected" ]]
|
||||
then
|
||||
con=$(nmcli | grep "connected to" | sed "s/.*: connected to \(.*\)/\1/g")
|
||||
con=$(nmcli | awk -F "to " '/connected to/ { print $2 }')
|
||||
echo "" $con
|
||||
else
|
||||
echo ""
|
||||
|
||||
Reference in New Issue
Block a user