From 0d374a5f82b88177d2fdaf35d9c28080a8f35494 Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Tue, 4 Nov 2025 16:37:44 +0000 Subject: 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. --- Scripts/.local/scripts/status/connection | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Scripts/.local/scripts/status/connection') diff --git a/Scripts/.local/scripts/status/connection b/Scripts/.local/scripts/status/connection index 84f84dc..5c566fb 100755 --- a/Scripts/.local/scripts/status/connection +++ b/Scripts/.local/scripts/status/connection @@ -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 "" -- cgit v1.2.3-13-gbd6f